What can cause the “topology was destroyed” error when calling db.destroyDatabase using node.js mongodb native?

I am running some integration tests with / w 630> .js Mongodb native driver. Each test includes connecting to a database, confirming that it does not exist yet (for example, there are no collections with documents), running the test and then deleting the database. The high-level code is as follows:

const runSafeTest = function runSafeTest(test) {
  async.waterfall([
    connectToMongo,
    throwIfDbExists,
    instantiateServerConnection,
    test
  ],
  function doneWaterfall(err, db) {
    db.dropDatabase(function(dbErr) {
      if (dbErr) throw dbErr
    });
  })
};

With each call, db.dropDatabase()it produces the following error:

MongoError: topology was destroyed

, : "" MongoDB ? Mongo, SO, , " " .

!

+4
1

, - - , db.close() db, db.dropDatabase(). " " - (, " " ), .

+16

Source: https://habr.com/ru/post/1613112/


All Articles