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

Utils getTopology should not throw unhandled exception

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.4.1
    • Component/s: None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      What problem are you facing?

      When a connection is closed and the internal topology is destroyed, operations attempting to execute will get a thrown MongoNotConnectedError instead of the error being based passed to the callback of the operation.

      What driver and relevant dependency versions are you using?

      4.4.1

      Steps to reproduce?

      const { MongoClient } = require('mongodb');
      
      const repro = () => {
        const client = new MongoClient('mongodb://127.0.0.1:27017');
        client.connect((error) => {
          const db = client.db('test');
          const collection = db.collection('test');
          client.close(() => {
            // This will throw an error instead of passing in the callback.
            collection.find().toArray((err) => {
              console.log(err);
            });
          });
        });
      }
      
      repro();
      

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            dbeng-pm-bot TPM Jira Automations Bot
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: