mongoose.disconnect won't stop the connection if a reconnect is in progress #9531
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When using
autoReconnect: true
, the connection to mongodb is automatically restored once the database is up again. However ifmongoose.disconnect()
is invoked when the connection is in a disconnected state, the connection is not really terminated and would proceed with the automatic reconnection.This can be a problem in a production environment when a graceful shutdown of the application would hang if one connection is currently waiting to reconnect.
If the current behavior is a bug, please provide the steps to reproduce.
https://gist.github.com/dbellavista/e65aaf56719a6bd028b07ab3eb756f8e
What is the expected behavior?
The
mongoose.disconnect
method should prevent reconnection from happening, allowing the process to exit.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
The text was updated successfully, but these errors were encountered: