-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.3.4
-
Component/s: None
-
None
-
(copied to CRM)
-
Empty show more show less
Steps to reproduce:
1. Start a single-node replica set but do not initialize it.
mongod --replSet repro --port 37017 --dbpath ./data/db --logpath ./data/mongodb.log --fork
2. Run the following Node.js code (using Node.js Driver 3.3.4):
const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:37017'; const client = new MongoClient(url, {useUnifiedTopology:true}); client.connect((err, client) => { client.db('admin') .command({replSetInitiate: { _id: 'repro', members: [{_id: 0, host: 'localhost:37017'}] }}, (err) => console.log(err)); });
This results in a stack overflow:
$ node test.js /Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/core/sdam/topology.js:435 process.hrtime(), ^ RangeError: Maximum call stack size exceeded at NativeTopology.selectServer (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/core/sdam/topology.js:435:7) at selectServerForSessionSupport (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:186:12) at executeOperation (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:38:12) at /Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:192:5 at /Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/core/sdam/topology.js:444:9 at selectServers (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/core/sdam/topology.js:877:12) at NativeTopology.selectServer (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/core/sdam/topology.js:431:5) at selectServerForSessionSupport (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:186:12) at executeOperation (/Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:38:12) at /Users/james/Documents/mongodb-cases/00618581/repro/node_modules/mongodb/lib/operations/execute_operation.js:192:5
If you remove useUnifiedTopology:true, the code works as expected and initializes the replica set.