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

4.x driver allows directConnection=true with multiple hosts

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.0
    • Affects Version/s: 4.0.0, 4.2.2, 4.3.0
    • Component/s: None
    • 2
    • Not Needed

      https://github.com/mongodb/specifications/blob/master/source/uri-options/uri-options.rst#directconnection-uri-option-with-multiple-seeds-or-srv-uri says:

      The driver MUST report an error if the directConnection=true URI option is specified with multiple seeds.

      In reality:

      import { MongoClient } from 'mongodb';
      
      const url = 'mongodb://localhost:27017,localhost:27018,localhost:27019/?directConnection=true&replicaSet=replset';
      const client = await MongoClient.connect(url);
      console.log((await client.db('admin').command({ hello: 1 })).hosts);
      

      prints [ 'localhost:27017', 'localhost:27018', 'localhost:27019' ] with the 4.3.0 driver. With 3.7.3, this fails as expected (“directConnection option requires exactly one host”).

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: