Skip to content

Commit ae6f007

Browse files
committed
docs and force flag
1 parent 67421a1 commit ae6f007

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

src/client-side-encryption/auto_encrypter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ export class AutoEncrypter {
375375
/**
376376
* Cleans up the `_mongocryptdClient`, if present.
377377
*/
378-
async teardown(force: boolean): Promise<void> {
379-
await this._mongocryptdClient?.close(force);
378+
async teardown(): Promise<void> {
379+
await this._mongocryptdClient?.close();
380380
}
381381

382382
/**

src/encrypter.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { callbackify } from 'util';
2-
31
import { AutoEncrypter, type AutoEncryptionOptions } from './client-side-encryption/auto_encrypter';
42
import { MONGO_CLIENT_EVENTS } from './constants';
53
import { getMongoDBClientEncryption } from './deps';
64
import { MongoInvalidArgumentError, MongoMissingDependencyError } from './error';
75
import { MongoClient, type MongoClientOptions } from './mongo_client';
8-
import { type Callback } from './utils';
96

107
/** @internal */
118
export interface EncrypterOptions {
@@ -98,20 +95,16 @@ export class Encrypter {
9895
}
9996
}
10097

101-
closeCallback(client: MongoClient, force: boolean, callback: Callback<void>) {
102-
callbackify(this.close.bind(this))(client, force, callback);
103-
}
104-
105-
async close(client: MongoClient, force: boolean): Promise<void> {
98+
async close(client: MongoClient): Promise<void> {
10699
let error;
107100
try {
108-
await this.autoEncrypter.teardown(force);
101+
await this.autoEncrypter.teardown();
109102
} catch (autoEncrypterError) {
110103
error = autoEncrypterError;
111104
}
112105
const internalClient = this.internalClient;
113106
if (internalClient != null && client !== internalClient) {
114-
return await internalClient.close(force);
107+
return await internalClient.close();
115108
}
116109
if (error != null) {
117110
throw error;

src/mongo_client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,23 +645,23 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
645645
*
646646
* This includes:
647647
*
648-
* - Closes all open, unused connections (see note).
648+
* - Closes in-use connections.
649+
* - Closes all active cursors.
649650
* - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
651+
* - aborts in progress transactions if is one related to the session.
650652
* - Ends all unused sessions server-side.
653+
* - Closes all remaining idle connections.
651654
* - Cleans up any resources being used for auto encryption if auto encryption is enabled.
652655
*
653-
* @remarks Any in-progress operations are not killed and any connections used by in progress operations
654-
* will be cleaned up lazily as operations finish.
655-
*
656-
* @param force - Force close, emitting no events
656+
* @param _force - currently an unused flag that has no effect. Defaults to `false`.
657657
*/
658-
async close(force = false): Promise<void> {
658+
async close(_force = false): Promise<void> {
659659
if (this.closeLock) {
660660
return await this.closeLock;
661661
}
662662

663663
try {
664-
this.closeLock = this._close(force);
664+
this.closeLock = this._close();
665665
await this.closeLock;
666666
} finally {
667667
// release
@@ -670,7 +670,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
670670
}
671671

672672
/* @internal */
673-
private async _close(force = false): Promise<void> {
673+
private async _close(): Promise<void> {
674674
// There's no way to set hasBeenClosed back to false
675675
Object.defineProperty(this.s, 'hasBeenClosed', {
676676
value: true,
@@ -726,7 +726,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
726726

727727
const { encrypter } = this.options;
728728
if (encrypter) {
729-
await encrypter.close(this, force);
729+
await encrypter.close(this);
730730
}
731731
}
732732

0 commit comments

Comments
 (0)