Make MongoClient.connect optional

    • Type: Epic
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Native
    • None
    • Get rid of MongoClient.connect
    • Not Needed
    • Done
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Although we now conform to SDAM spec, we still diverge from other drivers in that we require an async call to MongoClient.prototype.connect before allowing operations on the client. This connect call involves many asynchronous actions like SRV resolution, instantiating connection pools, and initial server selection.

      Current flow:

      const client = new MongoClient('mongodb://localhost:27017');
      
      // This command will error b/c the client is not connected.
      await client.db('foo').collection('bar').insertOne({ a: 1 });
      
      // This is the proper workflow
      client.connect().then(async function() {
        await client.db('foo').collection('bar').insertOne({ a: 1 });
      });
      

      We'd like to eventually eliminate the need for this connect call so that all of the initial setup occurs as part of initial serverSelection.

              Assignee:
              Unassigned
              Reporter:
              Daniel Aprahamian (Inactive)
              None
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:
                None
                None
                None
                None
                None