Mongoose hangs indefinitely when disconnected
See original GitHub issueI 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:
- Created 7 years ago
- Comments:9
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
bufferCommands: false
in the schemabufferMaxEntries
to 0 likemongoose.connect(uri, { db: { bufferMaxEntries: 0 } })
Yes sir. Like this:
My goal is that any subsequent request to mongo going down will fail immediately