dan-divy/spruce

MongoError: Topology closed

Ased2235 opened this issue · 8 comments

Hello, when i run npm start it's showing this error

npm start

spruce@4.0.0 start
node update.js; node ./bin/www

Developer key: pxdo2rqHVVw1DMEHeYwXyE9nKwH5b3SxzB5pMVUs
Verify your account in /me with this key

spruce is listening on http://localhost:8000

home/senpai/code/spruce/node_modules/mongodb/lib/core/sdam/topology.js:325
drainWaitQueue(this[kWaitQueue], new MongoError('Topology closed'));
^

MongoError: Topology closed
at NativeTopology.close (/home/senpai/code/spruce/node_modules/mongodb/lib/core/sdam/topology.js:325:38)
at /home/senpai/code/spruce/node_modules/mongodb/lib/mongo_client.js:267:21
at maybePromise (/home/senpai/code/spruce/node_modules/mongodb/lib/utils.js:719:3)
at MongoClient.close (/home/senpai/code/spruce/node_modules/mongodb/lib/mongo_client.js:248:10)
at /home/senpai/code/spruce/node_modules/mongoose/lib/connection.js:711:20
at new Promise ()
at NativeConnection.Connection.openUri (/home/senpai/code/spruce/node_modules/mongoose/lib/connection.js:709:19)
at Mongoose.connect (/home/senpai/code/spruce/node_modules/mongoose/lib/index.js:335:15)
at Object. (/home/senpai/code/spruce/utils/models/keys.js:6:10)`
npm ERR! A complete log of this run can be found in:
npm ERR! /home/senpai/.npm/_logs/2021-06-07T13_48_06_101Z-debug.log

can anyone help me?
Thanks!

Hi @Ased2235, is this the same mongo version as listed on the github repo's package.json or did you install a later version?

Hi @Ased2235, is this the same mongo version as listed on the github repo's package.json or did you install a later version?

Same as github repo's package.json

The error says that the server connection was closed, so you need to reopen the connection. Perhaps the connection disconnected or was closed somewhere?

The error says that the server connection was closed, so you need to reopen the connection. Perhaps the connection disconnected or was closed somewhere?

But it's not closed as i have one more active connection to ping the server.

Hmm, the error reports that the database connection is closed are you sure you don't close the connection somewhere?

Hmm, the error reports that the database connection is closed are you sure you don't close the connection somewhere?

No, it's active I already tested it but only here it shows close error. I don't know why it is doing this.

Im getting the same error. Please lmk if this was fixed

For those of you running in to this error, the problem is indeed multiple parallel instances of Mongo being open. Save those connect calls to a separate script and import that.