-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
when mongoose.connect() returns an error the connection.readyState is set to 2 (connecting) #9921
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
aware
labels
Feb 23, 2021
This was referenced Mar 5, 2021
Closed
This was referenced Mar 12, 2021
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When mongoose.connect() throws an error, the mongoose.connection.readyState is sometimes 2 (connecting).
If the current behavior is a bug, please provide the steps to reproduce.
Once every 2-3 runs, the following logs are printed
connect error: querySrv ENOTFOUND _mongodb._tcp.badhost.rtiii.mongodb.net
mongoose.connect returned an error, but ready state is 2
The correct runs, just print
connect error: querySrv ENOTFOUND _mongodb._tcp.badhost.rtiii.mongodb.net
What is the expected behavior?
I would expect the ready state to be 0 (disconnected) if mongoose.connect() fails.
This may be related to #8692. The error does not happen with useUnifiedTopology false. However, in the case where mongoose.connect() fails I would expect the readyState to be appropriately set, not to be delayed by the serverSelectionTimeoutMS.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node 14.15.4
Mongoose 5.11.13
MongoDB - Atlas 4.4.3
I am running the code on OS X 11.2.
The text was updated successfully, but these errors were encountered: