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

MongoError: server instance pool was destroyed #125

Open
bhumilsarvaiya opened this issue May 3, 2018 · 1 comment
Open

MongoError: server instance pool was destroyed #125

bhumilsarvaiya opened this issue May 3, 2018 · 1 comment
Assignees

Comments

@bhumilsarvaiya
Copy link

Hello,
After my mongodb server goes down for around like 2 mins, I start getting this error. Also after the mongodb server is up after this point, no logs are getting added to mongo collection.

MongoError: server instance pool was destroyed
    at Function.MongoError.create (/home/app/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:29:11)
    at basicWriteValidations (/home/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:450:51)
    at Server.insert (/home/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:542:16)
    at Server.insert (/home/app/node_modules/mongodb/lib/server.js:390:17)
    at insertDocuments (/home/app/node_modules/mongodb/lib/collection.js:744:19)
    at insertOne (/home/app/node_modules/mongodb/lib/collection.js:439:3)
    at /home/app/node_modules/mongodb/lib/collection.js:431:5
    at new Promise (<anonymous>)
    at Collection.insertOne (/home/app/node_modules/mongodb/lib/collection.js:430:10)
    at process.nextTick (/home/app/node_modules/winston-mongodb/lib/winston-mongodb.js:217:44)

The way I am setting up mongodb with winston:

require("winston-mongodb").MongoDB;
let logger = new winston.Logger({
    transports: [
        new winston.transports.MongoDB({
            db: `mongodb://${user}:${password}@${mongodb}:27017/${db}`,
            collection: "logs"
        })
    ]
});

I also tried with tryReconnect option but it didn't help.
Please let me know if I am doing it wrongly or do I need some workaround.
Thanks

@HugoPoi
Copy link

HugoPoi commented Dec 22, 2020

I have a similar issue with my setup

winston-mongodb: error initialising logger Error: connect ECONNREFUSED XXX.XXX.XXX.XXX:27017
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  name: 'MongoNetworkError',
  errorLabels: [ 'TransientTransactionError' ],
  [Symbol(mongoErrorContextSymbol)]: {}
}

I use a replicaset and when a member is down, winston doesn't connect, my other mongodb driver instance working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants