Skip to content

Commit a68bb87

Browse files
add documentation of close methods"
1 parent 6ae7ff5 commit a68bb87

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/change_stream.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ export class ChangeStream<
554554
/**
555555
* @beta
556556
* @experimental
557+
* An alias for {@link ChangeStream.close|ChangeStream.close()}.
557558
*/
558559
declare [Symbol.asyncDispose]: () => Promise<void>;
559560
/** @internal */
@@ -779,7 +780,9 @@ export class ChangeStream<
779780
return this[kClosed] || this.cursor.closed;
780781
}
781782

782-
/** Close the Change Stream */
783+
/**
784+
* Frees the internal resources used by the change stream.
785+
*/
783786
async close(): Promise<void> {
784787
this[kClosed] = true;
785788

src/cursor/abstract_cursor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export abstract class AbstractCursor<
282282
/**
283283
* @beta
284284
* @experimental
285+
* An alias for {@link AbstractCursor.close|AbstractCursor.close()}.
285286
*/
286287
declare [Symbol.asyncDispose]: () => Promise<void>;
287288
/** @internal */
@@ -460,6 +461,9 @@ export abstract class AbstractCursor<
460461
}
461462
}
462463

464+
/**
465+
* Frees any client-side resources used by the cursor.
466+
*/
463467
async close(): Promise<void> {
464468
await this.cleanup();
465469
}

src/mongo_client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
408408
/**
409409
* @beta
410410
* @experimental
411+
* An alias for {@link MongoClient.close|MongoClient.close()}.
411412
*/
412413
declare [Symbol.asyncDispose]: () => Promise<void>;
413414
/** @internal */
@@ -581,7 +582,15 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
581582
}
582583

583584
/**
584-
* Close the client and its underlying connections
585+
* Cleans up client-side resources used by the MongoCLient and . This includes:
586+
*
587+
* - Closes all open, unused connections (see note).
588+
* - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
589+
* - Ends all unused sessions server-side.
590+
* - Cleans up any resources being used for auto encryption if auto encryption is enabled.
591+
*
592+
* @remarks Any in-progress operations are not killed and any connections used by in progress operations
593+
* will be cleaned up lazily as operations finish.
585594
*
586595
* @param force - Force close, emitting no events
587596
*/

src/sessions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ export class ClientSession
259259
}
260260

261261
/**
262-
* Ends this session on the server
262+
* Frees any client-side resources held by the current session. If a session is in a transaction,
263+
* the transaction is aborted.
264+
*
265+
* Does not end the session on the server.
263266
*
264267
* @param options - Optional settings. Currently reserved for future use
265268
*/
@@ -293,6 +296,7 @@ export class ClientSession
293296
/**
294297
* @beta
295298
* @experimental
299+
* An alias for {@link ClientSession.endSession|ClientSession.endSession()}.
296300
*/
297301
declare [Symbol.asyncDispose]: () => Promise<void>;
298302
/** @internal */

0 commit comments

Comments
 (0)