MCPcopy
hub / github.com/mongodb/node-mongodb-native / run

Function run

test/integration/node-specific/client_close.test.ts:91–118  ·  view source on GitHub ↗
({
              MongoClient,
              uri,
              expect,
              sleep,
              mongodb,
              getTimerCount
            })

Source from the content-addressed store, hash-verified

89 metadata,
90 async function () {
91 const run = async function ({
92 MongoClient,
93 uri,
94 expect,
95 sleep,
96 mongodb,
97 getTimerCount
98 }) {
99 const serverSelectionTimeoutMS = 2222;
100 const client = new MongoClient(uri, {
101 minPoolSize: 1,
102 serverSelectionTimeoutMS,
103 readPreference: new mongodb.ReadPreference('secondary', [
104 { something: 'that does not exist' }
105 ])
106 });
107 const insertPromise = client.db('db').collection('collection').insertOne({ x: 1 });
108
109 // don't allow entire server selection timer to elapse to ensure close is called mid-timeout
110 await sleep(serverSelectionTimeoutMS / 2);
111
112 expect(getTimerCount()).to.not.equal(0);
113 await client.close();
114 expect(getTimerCount()).to.equal(0);
115
116 const err = await insertPromise.catch(e => e);
117 expect(err).to.be.instanceOf(mongodb.MongoTopologyClosedError);
118 };
119 await runScriptAndGetProcessInfo('timer-server-selection', this.configuration, run);
120 }
121 );

Callers

nothing calls this directly

Calls 15

dbMethod · 0.95
closeMethod · 0.95
connectMethod · 0.95
getTimerCountFunction · 0.85
onceFunction · 0.85
monitorTimersExistFunction · 0.85
getMonitorTimerFunction · 0.85
getSocketEndpointsFunction · 0.85
getRttTimerFunction · 0.85
getSocketsFunction · 0.85
getMinPoolSizeTimerFunction · 0.85

Tested by

no test coverage detected