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

Function autoConnect

src/operations/execute_operation.ts:144–163  ·  view source on GitHub ↗
(client: MongoClient)

Source from the content-addressed store, hash-verified

142 * @internal
143 */
144export async function autoConnect(client: MongoClient): Promise<Topology> {
145 if (client.topology == null) {
146 if (client.s.hasBeenClosed) {
147 throw new MongoNotConnectedError('Client must be connected before running operations');
148 }
149 client.s.options.__skipPingOnConnect = true;
150 try {
151 await client.connect();
152 if (client.topology == null) {
153 throw new MongoRuntimeError(
154 'client.connect did not create a topology but also did not throw'
155 );
156 }
157 return client.topology;
158 } finally {
159 delete client.s.options.__skipPingOnConnect;
160 }
161 }
162 return client.topology;
163}
164
165/** @internal */
166type RetryOptions = {

Callers 2

bulkWriteMethod · 0.90
executeOperationFunction · 0.85

Calls 1

connectMethod · 0.45

Tested by

no test coverage detected