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

TypeError: Cannot read property 'commandsTakeWriteConcern' of null #8187

Closed
lalit117 opened this issue Sep 21, 2019 · 1 comment
Closed

TypeError: Cannot read property 'commandsTakeWriteConcern' of null #8187

lalit117 opened this issue Sep 21, 2019 · 1 comment
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary

Comments

@lalit117
Copy link

lalit117 commented Sep 21, 2019

mongoose version: 5.5.0

I am executing aggregation query on mongodb as soon as connection established.
but I am getting below issue sometimes and sometimes query get executed successfully

some people facing same issue but while dropping db
4490

I am attaching stack trace :

(node:1) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to

(node:1) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

**TypeError: Cannot read property 'commandsTakeWriteConcern' of null

File "/srv/slingshot/node_modules/mongoose/node_modules/mongodb/lib/operations/aggregate.js", line 53, col 52, in aggregate
const takesWriteConcern = topology.capabilities().commandsTakeWriteConcern;

File "/srv/slingshot/node_modules/mongoose/node_modules/mongodb/lib/collection.js", line 1694, col 10, in Collection.aggregate
return aggregate(this.s.db, this, pipeline, options, callback);

File "/srv/slingshot/node_modules/newrelic/lib/shim/shim.js", line 946, col 24, in Collection.wrapper [as aggregate]
return fnApply.call(fn, this, arguments)

File "/srv/slingshot/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js", line 146, col 28, in NativeCollection.(anonymous function) [as aggregate]
return collection[i].apply(collection, args);

File "/srv/slingshot/node_modules/mongoose/lib/collection.js", line 126, col 30, in NativeCollection.Collection.doQueue
this[this.queue[i][0]].apply(this, this.queue[i][1]);

File "/srv/slingshot/node_modules/mongoose/lib/collection.js", line 86, col 24, in immediate
immediate(() => this.doQueue());
File "internal/process/next_tick.js", line 70, col 11, in process.internalTickCallback

I am not able to write exact steps to reproduce issue, as it occurring randomly.
can anyone provide me help regarding this issue, what could be reason for issue ?
Thanks in advance.

@vkarpov15 vkarpov15 added this to the 5.7.4 milestone Sep 26, 2019
@vkarpov15 vkarpov15 added needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue underlying library issue This issue is a bug with an underlying library, like the MongoDB driver or mongodb-core labels Sep 26, 2019
@vkarpov15
Copy link
Collaborator

Not much I can really do about this issue without seeing some of your code, but here's a few suggestions for what you can do:

  1. Make sure you wait for mongoose.connect() to succeed before executing your aggregate() call, using mongoose.connect().then(cb) or await mongoose.connect()

  2. Try running without New Relic. New Relic does a lot of monkeypatching and has been known to cause bugs with MongoDB.

  3. Upgrade to Mongoose 5.7, which no longer has the offending code.

@vkarpov15 vkarpov15 removed needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue underlying library issue This issue is a bug with an underlying library, like the MongoDB driver or mongodb-core labels Oct 7, 2019
@vkarpov15 vkarpov15 removed this from the 5.7.4 milestone Oct 7, 2019
@vkarpov15 vkarpov15 added the help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary label Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Projects
None yet
Development

No branches or pull requests

2 participants