Hey,
I’m currently facing the issue that mongoose stops working if one of the replica set members given in the connection string is offline.
I currently have 2 replica set members on two different servers and I just want mongoose to use one or the other, depending on which one is reachable. The problem here is that as soon as I stop one of the servers, it is throwing the following error:
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:372:5)
at URL.onParseError (node:internal/url:563:9)
at new URL (node:internal/url:643:5)
at isAtlas (/test/node_modules/mongoose/lib/helpers/topology/isAtlas.js:17:17)
at MongooseServerSelectionError.assimilateError (/test/node_modules/mongoose/lib/error/serverSelection.js:35:35)
at /test/node_modules/mongoose/lib/connection.js:813:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
input: 'host4.example.com:27017',
code: 'ERR_INVALID_URL'
}
When I start the “host4.example.com” server, everything works again.
Any idea on how to tell mongoose to ignore that one of the servers is not available?
Thanks in advance for the help