Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: With the plugin, updateOne hangs, if nothing was found #71

Closed
maxsimych opened this issue Sep 25, 2020 · 8 comments · Fixed by #73
Closed

Bug: With the plugin, updateOne hangs, if nothing was found #71

maxsimych opened this issue Sep 25, 2020 · 8 comments · Fixed by #73

Comments

@maxsimych
Copy link

If nothing was found with updateOne, (same for update and updateMany) query just hangs without response.

When I turn off the plugin, I get correct result from the query:
{ n: 0, nModified: 0, ok: 1 }

versions:
node: 14.11.0
mongodb: 3.6.2
mongoose: 5.10.6
mongoose-patch-history: the version from github master

config:

Schema.plugin(patchHistory, {
  mongoose, name: 'ModelPatches', trackOriginalValue: true, removePatches: false
})
@vinerich
Copy link
Collaborator

Here we go again :D Thanks for the report.

This should be covered by testing but I think I'll have to include a few more versions.

@vinerich
Copy link
Collaborator

Just to keep you updated. With a newer mongoose version this behaviour is indeed happening over all node versions.
I'll need to find out what causes that odd behaviour, might take a while.

Else, if you would like to help out, you can try to pin down the specific minor mongoose version.
Only thing I can say is that it is somewhere between 5.6 and 5.10.

@maxsimych
Copy link
Author

Checked!
It works in 5.9.6
But stops to work in 5.9.7

@maxsimych
Copy link
Author

@vinerich hello, any news?)

@vinerich
Copy link
Collaborator

vinerich commented Oct 4, 2020

@maxsimych Thanks for bumping! It must've slipt through.

Somewhere along the versions 5.9 to 5.10 several changes where introduced:

  • Plugin hook functions must (!) call next(), simply calling return while leave a non-returning promise.
  • When upserting a document the query result changed from { nModified: 1, ... } to { nModified: 0, upserted: [docs], ... }

So I changed the nModified check to include the new upserted property and am calling next() to return.

Will write PRs and then you should be good to go.

@vinerich
Copy link
Collaborator

@codepunkt I know time is spare. Just want to bump the PR if you got the time.

@codepunkt
Copy link
Owner

codepunkt commented Jan 8, 2021

@vinerich you should have contributor permissions - atleast I sent out an invite 😉

@vinerich
Copy link
Collaborator

vinerich commented Jan 8, 2021

@codepunkt I should indeed have, if I didn't forgot it about the new years. Invitation is expired, can you resend it? I'll accept this time :D Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants