Skip to content

Commit e28ecff

Browse files
committed
clarify docs based on comments
1 parent afa82d5 commit e28ecff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/mongo_client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,16 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
656656
/**
657657
* Cleans up resources managed by the MongoClient.
658658
*
659-
* The close method clears and closes all resources that the client is responsible for.
660-
* Please refer to the `MongoClient` class documentation for a breakdown of resource responsibilities.
659+
* The close method clears and closes all resources whose lifetimes are managed by the MongoClient.
660+
* Please refer to the `MongoClient` class documentation for a high level overview of the client's key features and responsibilities.
661661
*
662-
* **However,** the close method is not a replacement for clean up of explicitly created resources.
662+
* **However,** the close method does not handle the cleanup of resources explicitly created by the user.
663+
* Any user-created driver resource with its own `close()` method should be explicitly closed by the user before calling MongoClient.close().
663664
* This method is written as a "best effort" attempt to leave behind the least amount of resources server-side when possible.
664665
*
665666
* The following list defines ideal preconditions and consequent pitfalls if they are not met.
667+
* The MongoClient, ClientSession, Cursors and ChangeStreams all support [explicit resource management](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html).
668+
* By using explicit resource management to manage the lifetime of driver resources instead of manually managing their lifetimes, the pitfalls outlined below can be avoided.
666669
*
667670
* The close method performs the following in the order listed:
668671
* - Client-side:

0 commit comments

Comments
 (0)