question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongoose hangs indefinitely when disconnected

See original GitHub issue

I hava a koajs/mongoose REST service and when mongoDB goes down, all requests that hit my REST service hang indefinitely. I’m trying to configure mongoose in a way that it would fail any command when mongoose is not connected to mongo. Is this possible? I have tried using bufferCommands: false on my Schemas but it doesn’t seem to do anything.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
vkarpov15commented, Oct 22, 2016

Mongoose and the mongodb driver both have their own buffering layers (something we’re hoping to remove in a subsequent release) so in order to have operations fail fast but the driver continues to reconnect in the background you need to:

  1. Upgrade to 4.6.5 once it’s released (should be today)
  2. Disable mongoose buffering with bufferCommands: false in the schema
  3. Set the driver’s bufferMaxEntries to 0 like mongoose.connect(uri, { db: { bufferMaxEntries: 0 } })
1reaction
ulisesbocchiocommented, Oct 1, 2016

Yes sir. Like this:

var schema = new Schema({..}, { bufferCommands: false });

My goal is that any subsequent request to mongo going down will fail immediately

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongoose hanging on disconnect - node.js - Stack Overflow
I have a mongoose application that is running a scheduled task on a periodic basis. Unfortunately, after the first time this is run,...
Read more >
Managing Connections with the MongoDB Node.js Driver
By default, the MongoDB driver stops trying to reconnect to a single server after 30 seconds. Specifically, the driver will retry ...
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
Let's say we have a server running. It's receiving requests and establishing connections with clients. But what happens if the process crashes?
Read more >
Node.js v19.3.0 Documentation
Recursion stops when both sides differ or both sides encounter a circular reference. WeakMap and WeakSet comparison does not rely on their values....
Read more >
mongoose - Archive - Google Code
ID Status Summary 210 Fixed non‑parsed CGI Type‑Defect Priority‑Medium 199 Done non‑parsed CGI Type‑Defect Priority‑Medium 195 Invalid PHP‑CGI Problem Type‑Defect Priority‑Medium
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found