Mongoose doesn't shut down gracefully
See original GitHub issueMongoose never lets the node event loop clear, even after disconnect is called. This stops node from exiting gracefully (i.e. without calling process.exit()) Other server modules allow node to shutdown after it’s respective .close() or .shutdown() is called, including Restify, Express, etc. Mongoose, however, holds the application open.
This application never exits:
//Boilerplate
var mongoose = require('mongoose');
var db = mongoose.connection;
db.on('error', function(err) {
console.log('Mongoose connection error: ' + err);
});
//connect
mongoose.connect("localhost");
//disconnect
mongoose.disconnect();
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:18
Top Results From Across the Web
How do I gracefully shutdown mongoose's connection pool?
Most documentation/tutorials state that to stop a connection (or pool of connections), I must use mongoose.disconnect() - which calls .close() ...
Read more >Mongodb not shutting down via --shutdown command
When mongod gets the SIGTERM command(default signal of kill command is SIGTERM), it will shutdown the database gracefully.
Read more >Graceful shutdown in NodeJS - HackerNoon
Graceful shutdown means when all your requests to the server is respond and not any data processing work left. You can not know...
Read more >Graceful Shutdown | Best Practices | PM2 Documentation
Failed requests can be avoided with graceful shutdown and restart. This tutorial introduce you how to implement it. Graceful Shutdown. In a graceful...
Read more >Let It Crash: Best Practices for Handling Node.js Errors on ...
Some strategies to gracefully shutdown the Node.js process and quickly restart your application after a catastrophic error terminates your ...
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 FreeTop 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
Top GitHub Comments
vkarpov15 it’s here
This is still an issue for me. Mongoose 5.0.4, Node 4.2.1. After running
disconnect()
, the process keeps running. Is this the same issue as https://github.com/Automattic/mongoose/issues/3358?