* 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)
| 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 }; |
no test coverage detected