mirror of
https://github.com/hanzoai/mongodb-memory-server.git
synced 2026-09-24 17:00:24 +00:00
fix(ReplSet): add HACK for "Maximum call stack size exceeded" in MongoClient topology
Closes #221
This commit is contained in:
@@ -242,6 +242,17 @@ export default class MongoMemoryReplSet extends EventEmitter {
|
||||
|
||||
try {
|
||||
const db = await conn.db(this.opts.replSet.dbName);
|
||||
|
||||
// MongoClient HACK which helps to avoid the following error:
|
||||
// "RangeError: Maximum call stack size exceeded"
|
||||
// in ./node_modules/mongodb/lib/core/sdam/topology_description.js:263:51
|
||||
// Under the hood initiated server topology has type `RSGhost`
|
||||
// and this server does not support session
|
||||
// so for skipping the following code
|
||||
// https://github.com/mongodb/node-mongodb-native/blob/dc70c2de7d3dae2617708c45a1ea695d131e15f3/lib/operations/execute_operation.js#L33-L39
|
||||
// we just override shouldCheckForSessionSupport() method for current connection instance
|
||||
(db as any).topology.shouldCheckForSessionSupport = () => false;
|
||||
|
||||
this.admin = db.admin();
|
||||
const members = uris.map((uri, idx) => ({ _id: idx, host: getHost(uri) }));
|
||||
const rsConfig = {
|
||||
|
||||
Reference in New Issue
Block a user