Skip to content

Intermittent strange "Invalid argument to findOne()" with Mongoose 4.7 and Node 7 #5163

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

Closed
brettkiefer opened this issue Apr 12, 2017 · 1 comment

Comments

@brettkiefer
Copy link

We are seeing an intermittent bug when using Mongoose 4.7.7-pre (1ddadf8) and Node 7.7.1 under heavy load. We have only been able to reproduce it in production and in our staging environment, and only very infrequently.

The bug does not occur under Node 6.10.

It manifests as either "Invalid argument to findOne(): { QUERY CONTENTS }" or as "Invalid select() argument. Must be string or object.", and we have seen it only with very frequently-executed queries, with no other pattern.

The bug seems to lead down to mquery.canMerge and from there to mquery.isObject. We think it is dangerous because most calls to canMerge don't do the same check that findOne does -- that is, they will silently fail to merge the query condition rather than erroring out. That could lead to empty or incomplete find() or update() queries.

It looks as though at least one other person is seeing or has seen the problem: http://stackoverflow.com/questions/42397994/dark-mongoose-magic-invalid-argument-to-findone

We are attempting to get a reliable repro right now, but wanted to give a heads-up and see if anyone else had seen anything like this. We are not suggesting that it is a bug in Mongoose or Mquery necessarily, but this is the only place where it is showing up for us. We intend to test other Mongoose versions when we can reproduce consistently. Currently we are not able to upgrade to Node 7 in production because we cannot reproduce this issue reliably.

Again, we realize this probably isn't enough information to go on, but wanted to post here to see if this rang any bells for the Mongoose contributors. We'll post more as we (hopefully) progress.

@brettkiefer
Copy link
Author

@Sebmaster thinks he's found the v8 bug causing this: nodejs/node#12411 and https://bugs.chromium.org/p/chromium/issues/detail?id=664506

Closing this as that seems very probably what's causing it.

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

No branches or pull requests

1 participant