-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.2.7, 3.3.2
-
Component/s: None
-
Environment:Node: v12.7.0
MongoDB native driver: "mongodb": "^3.3.2",
MongoDB daemon: 4.0.10
-
(copied to CRM)
-
Empty show more show less
Creating a MongoClient instance with useUnifiedTopology: true causes the following issues:
- MongoClient.isConnected() always returns true, even if server got disconnected many seconds ago (even exceeding the reconnectTries*reconnectInterval period), but a subsequent query triggers an error: MongoError: server instance pool was destroyed).
- No "timeout", "error", "reconnect", "reconnectFailed" events are triggered.
I need to detect when the MongoClient failed to reconnect (reconnectTries) times to the server to react accordingly (in this specific case, I just want to re-instantiate MongoClient after a timeout.
For me, using the topology monitoring events doesn't help/make sense as well, as I need to detect this specific behaviour.
The only available option I have is to exit the node process abruptly in that case, to later restart it with something like pm2.
I don't really understand how these documented features are not properly working in any of the latest node-mongo-driver versions?
Thanks.