We have several nodejs daemons that make use of mongoose while sharing the same persistence layer (shared module containing the queries).
In one of these daemons (always the same one) we randomly (few times a week) get the following error from mongoose:
mongoose: Invalid argument to findOne()
We've checked all queries and were not able to find out where this might come from. The errors call stack is different every time (no specific mongoose call seems to cause this issue) so we don't think this is specific to the business logic.
In order to do some debugging we added the following logging in case the error happens again:
log({
// What mongoose checks (both false -> the error).
isInstanceOfMQuery: conds instanceof mquery,
isObject: mquery.utils.isObject(conds),
// Trying to find out what this value is.
conds,
toString: Object.prototype.toString.call(conds)
inspect: util.inspect(conds, { showHidden: true, depth: null, showProxy: true })
})
conds
is the argument that mongoose is complaining about. log() will JSON.stringify() the whole thing.
This is one of the logs that resulted from this call:
{
"isInstanceOfMQuery": false,
"isObject": false,
"conds": {},
"toString": "[object Null]"
"inspect": "{}",
}
Now this confuses me even more... how can conds be {}
and null
at the same time?!
Answers I'm looking for:
Any ideas appreciated!
This is probably a node bug with the PR to fix here. It's not yet included in a release.
It's not reliably reproducible since it seems to depend on pointers and v8's garbage collection. Just gotta wait for it to be fixed upstream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With