-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Random "MongoServerSelectionError", reason : "ReplicaSetNoPrimary" #11228
Comments
Without more code samples, not really possible for us to try to repro this. Same stack trace as #11200, but the stack trace doesn't help much because we get the same stack trace from just about any MongoDB operation that times out. One potentially useful bit of info: did you omit the contents of the |
@vkarpov15 nope, the |
Can you link me to the "I connect with the script dbConnect from the official Next.js repo with-mongodb-mongoose." that you mentioned? |
The file I'm talking about is the following : https://github.com/vercel/next.js/blob/canary/examples/with-mongodb-mongoose/lib/dbConnect.js
|
Worth noting: based on your comment, you aren't using Mongoose. We'll take some time to set up an example with Next hosting and see if we can repro this. |
I set up a Vercel GitHub repo and deployed it: https://github.com/vkarpov15/with-mongodb-mongoose-3 , a quick check shows no errors: Without more complete code samples, there isn't really much we can do to repro this. I suggest you:
// Handle errors on save, etc.
schema.post(/.*/, { document: true, query: false }, function(err, res, next) {
console.log('Error on document op:', this.$op, this.model.modelName);
console.log(err);
next(err);
});
// Handle errors on find, findOne, etc.
schema.post(/.*/, { document: false, query: true }, function(err, res, next) {
console.log('Error on query:', this.model.modelName, this.op);
console.log(err);
next(err);
}); For example, if I shut down my local MongoDB server before a
This can at least point you in the direction of where in your code this error is coming from. |
Maybe a network or security group problem? |
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
I occasionally get the following error
It seems similar to this issue #11200, but I had that problem before switching from v5 to v6.
I use Next.js hosting on Vercel, so I use Lambda functions. I connect with the script
dbConnect
from the official Next.js repowith-mongodb-mongoose
.Also, this happens for different endpoints.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJs : 14.x
Mongoose : 6.1.6
MongoDB : Mongoose dependency
The text was updated successfully, but these errors were encountered: