Skip to content

MongoError: server is closed #19

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

Open
chrisueda opened this issue Mar 24, 2020 · 3 comments
Open

MongoError: server is closed #19

chrisueda opened this issue Mar 24, 2020 · 3 comments

Comments

@chrisueda
Copy link

chrisueda commented Mar 24, 2020

Getting this error MongoError: server is closed right before the should have correct fields user test when running this command: yarn test exercises/models/__test__/user.spec.js. Strangely if I remove the previous betaUser should default to false test, the error goes away.

Full error:


    MongoError: server is closed

      at executeWriteOperation (node_modules/mongodb/lib/core/sdam/server.js:439:14)
      at Server.insert (node_modules/mongodb/lib/core/sdam/server.js:372:5)
      at Object.callback (node_modules/mongodb/lib/core/sdam/topology.js:938:15)
      at processWaitQueue (node_modules/mongodb/lib/core/sdam/topology.js:1036:21)
      at NativeTopology.selectServer (node_modules/mongodb/lib/core/sdam/topology.js:440:5)
      at executeWriteOperation (node_modules/mongodb/lib/core/sdam/topology.js:906:12)
      at NativeTopology.insert (node_modules/mongodb/lib/core/sdam/topology.js:595:5)
      at NativeTopology.insert (node_modules/mongodb/lib/topologies/native_topology.js:54:11)
      at insertDocuments (node_modules/mongodb/lib/operations/common_functions.js:259:19)
      at InsertOneOperation.execute (node_modules/mongodb/lib/operations/insert_one.js:26:5)
      at executeOperation (node_modules/mongodb/lib/operations/execute_operation.js:77:17)
      at Collection.Object.<anonymous>.Collection.insertOne (node_modules/mongodb/lib/collection.js:516:10)
      at NativeCollection.<computed> [as insertOne] (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:171:28)
      at model.Object.<anonymous>.Model.$__handleSave (node_modules/mongoose/lib/model.js:273:33)
      at model.Object.<anonymous>.Model.$__save (node_modules/mongoose/lib/model.js:337:8)
      at node_modules/kareem/index.js:278:20```
@b3nk3
Copy link

b3nk3 commented Mar 30, 2020

Hey there, I struggle with similar issues - I traced it back to connections pooling, and closing early.

Happens on the solution branch too.

Playing around with the following seems to help somewhat

mongoose.connect('mongodb://localhost/', {
    poolSize: 15,
    useNewUrlParser: true,
    useUnifiedTopology: true
  }

throwing error: MongoError: server is closed

without useUnifiedTopology it throws: MongoError: pool is draining, new operations prohibited

@b3nk3
Copy link

b3nk3 commented Mar 30, 2020

Getting this error MongoError: server is closed right before the should have correct fields user test when running this command: yarn test exercises/models/__test__/user.spec.js. Strangely if I remove the previous betaUser should default to false test, the error goes away.

Full error:


    MongoError: server is closed

      at executeWriteOperation (node_modules/mongodb/lib/core/sdam/server.js:439:14)
      at Server.insert (node_modules/mongodb/lib/core/sdam/server.js:372:5)
      at Object.callback (node_modules/mongodb/lib/core/sdam/topology.js:938:15)
      at processWaitQueue (node_modules/mongodb/lib/core/sdam/topology.js:1036:21)
      at NativeTopology.selectServer (node_modules/mongodb/lib/core/sdam/topology.js:440:5)
      at executeWriteOperation (node_modules/mongodb/lib/core/sdam/topology.js:906:12)
      at NativeTopology.insert (node_modules/mongodb/lib/core/sdam/topology.js:595:5)
      at NativeTopology.insert (node_modules/mongodb/lib/topologies/native_topology.js:54:11)
      at insertDocuments (node_modules/mongodb/lib/operations/common_functions.js:259:19)
      at InsertOneOperation.execute (node_modules/mongodb/lib/operations/insert_one.js:26:5)
      at executeOperation (node_modules/mongodb/lib/operations/execute_operation.js:77:17)
      at Collection.Object.<anonymous>.Collection.insertOne (node_modules/mongodb/lib/collection.js:516:10)
      at NativeCollection.<computed> [as insertOne] (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:171:28)
      at model.Object.<anonymous>.Model.$__handleSave (node_modules/mongoose/lib/model.js:273:33)
      at model.Object.<anonymous>.Model.$__save (node_modules/mongoose/lib/model.js:337:8)
      at node_modules/kareem/index.js:278:20```

PR #17 seems to be providing the most consistent results so far.

@mkelley33
Copy link

PR #17 ftw

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

No branches or pull requests

3 participants