I am running some integration tests w/ the Node.js Mongodb native driver. Each test involves connecting to a database, verifying that it doesn't already exist (e.g. doesn't have any collections w/ documents), running a test, and then dropping the database. 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
});
})
};
Every time db.dropDatabase()
gets called it throws the following error:
MongoError: topology was destroyed
Not asking for specific debugging of the above code, but rather just a general question: what does a "topology was destroyed" error in MongoDB mean and what kinds of things could cause it? Have looked through the Mongo docs, the source code, and the other SO questions, but can't find a clear answer on what "topology was destroyed" means and how i might prevent it from manifesting in the testing approach we're using.
Thanks!