question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error `Cannot read property 'commandsTakeWriteConcern' of null` in v4.6.0

See original GitHub issue

On the line mongoose.connection.db.dropDatabase( done ); We are getting the error

Cannot read property 'commandsTakeWriteConcern' of null
      at decorateWithWriteConcern (/redacted/node_modules/mongoose/node_modules/mongodb/lib/db.js:485:36)
      at Db.dropDatabase (/redacted/node_modules/mongoose/node_modules/mongodb/lib/db.js:872:3)
      at Array.db.dropDatabase (/redacted/src/db/index.js:20:25)
      at node_modules/async/lib/async.js:596:38
      at _arrayEach (node_modules/async/lib/async.js:85:13)
      at Object.async.auto (node_modules/async/lib/async.js:554:9)
      at Context.<anonymous> (test/config.js:25:9)

However the version mongoose@4.5.9 works fine.

Thanks in advance

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

10reactions
ct5845commented, Sep 12, 2016

I had the same issue. I got it working by changing where i had my drop statement to;

mongoose.connection.once('connected', () => {
    mongoose.connection.db.dropDatabase();
});
7reactions
vkarpov15commented, Oct 22, 2016

Use this instead:

mongoose.connection.dropDatabase(error => {
  console.log('Error', error);
  process.exit(0);
});

The way we fixed this issue was adding a dropDatabase helper in mongoose that ties in with mongoose’s buffering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'commandsTakeWriteConcern' of null
This query producing strange behaviour. Sometime it gets executed. But sometime it is giving below error. ==================== ...
Read more >
TypeError: Cannot read property 'db' of null - node.js
The error message means that client is null in client.db - have you checked if err has any content? – VLAZ. Jan 1,...
Read more >
Cannot read property "username" of null - YelpCamp 2021 ...
In this quick video I will show you how to fix a common bug when working on the YelpCamp project from Colt Steele's...
Read more >
MongoDB and Mongoose - test timed out - JavaScript
Everytime I submit the reply page, the tests on the freecodecamp page say 'test timed out'. My bash terminal is showing that there's...
Read more >
mongodb @ 3.1.0 .. 3.2.3 - Package Diff
.catch(err => /* no error is thrown for bulk errors */); ... -removed in the MongoDB 4.0 release, and we are choosing to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found