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

Method cleanup

src/cmap/connection.ts:356–367  ·  view source on GitHub ↗

* A method that cleans up the connection. When `force` is true, this method * forcibly destroys the socket. * * If an error is provided, any in-flight operations will be closed with the error. * * This method does nothing if the connection is already closed.

(error: Error)

Source from the content-addressed store, hash-verified

354 * This method does nothing if the connection is already closed.
355 */
356 private cleanup(error: Error): void {
357 if (this.closed) {
358 return;
359 }
360
361 this.socket.destroy();
362 this.error = error;
363
364 this.dataEvents?.throw(error).then(undefined, squashError);
365 this.closed = true;
366 this.emit(Connection.CLOSE);
367 }
368
369 private prepareCommand(db: string, command: Document, options: CommandOptions) {
370 let cmd = { ...command };

Callers 7

onErrorMethod · 0.95
onCloseMethod · 0.95
onTimeoutMethod · 0.95
destroyMethod · 0.95
closeFunction · 0.45
cursorInitFunction · 0.45
fetchBatchFunction · 0.45

Calls 2

emitMethod · 0.65
destroyMethod · 0.45

Tested by

no test coverage detected