-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.7, 3.3.0
-
Component/s: Native
-
None
-
Environment:native driver
-
Empty show more show less
In other drivers, when ServerSelection occurs, it always waits the full serverSelectionTimeout before failing. This allows, for example, for a driver to issue a command while a server is still starting up. When the server is available for connections, the driver will finally resolve server selection, and issue the command.
On this line, we will quickly terminate Server Selection if a topology description change causes an error. This will cause ServerSelection to automatically fail if an error is experienced.
To reproduce:
- Attempt to connect a MongoClient to a port where there is no server running
- 100ms after the connect call, launch a mongod on that port
Current Behavior: Immediately fails to connect
What we should be doing: waiting until either server selection timeout, or until server can be connected to.
Snippet:
const assert = require('assert'); const { spawn } = require('child_process'); const { MongoClient } = require('mongodb'); const client = new MongoClient('mongodb://localhost:27017/', { useUnifiedTopology: true }); client.connect(err => { assert.ifError(err); }); setTimeout(() => spawn('mongod', { stdio: 'ignore'}), 100);
- duplicates
-
NODE-2121 SDAM should respect serverSelectionTimeoutMS when erroring on initial connect
- Closed