Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2147

Unexpected behaviours using useUnifiedTopology: true

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.5
    • Affects Version/s: 3.2.7, 3.3.2
    • Component/s: None
    • Labels:
    • Environment:
      Node: v12.7.0
      MongoDB native driver: "mongodb": "^3.3.2",
      MongoDB daemon: 4.0.10

      Creating a MongoClient instance with useUnifiedTopology: true causes the following issues:

      1. 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).
      2. 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.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            info@malagadev.com Jorge Duarte Rodriguez
            Votes:
            12 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: