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

Method close

src/cmap/connection_pool.ts:491–517  ·  view source on GitHub ↗

Close the pool

()

Source from the content-addressed store, hash-verified

489
490 /** Close the pool */
491 close(): void {
492 if (this.closed) {
493 return;
494 }
495
496 // immediately cancel any in-flight connections
497 this.cancellationToken.emit('cancel');
498
499 // end the connection counter
500 if (typeof this.connectionCounter.return === 'function') {
501 this.connectionCounter.return(undefined);
502 }
503
504 this.poolState = PoolState.closed;
505 this.clearMinPoolSizeTimer();
506 this.processWaitQueue();
507
508 for (const conn of this.connections) {
509 this.emitAndLog(
510 ConnectionPool.CONNECTION_CLOSED,
511 new ConnectionClosedEvent(this, conn, 'poolClosed')
512 );
513 conn.destroy();
514 }
515 this.connections.clear();
516 this.emitAndLog(ConnectionPool.CONNECTION_POOL_CLOSED, new ConnectionPoolClosedEvent(this));
517 }
518
519 /**
520 * @internal

Callers 7

constructorFunction · 0.45
[Symbol.asyncDispose]Function · 0.45
[Symbol.asyncIterator]Function · 0.45
transformDocumentFunction · 0.45
_destroyMethod · 0.45
_readNextMethod · 0.45
getMoreMethod · 0.45

Calls 6

clearMinPoolSizeTimerMethod · 0.95
processWaitQueueMethod · 0.95
emitAndLogMethod · 0.80
emitMethod · 0.65
destroyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected