mongodb 6.16.0-dev.20250506.sha.6a35701d → 6.16.0-dev.20250510.sha.6fe6ccc8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/beta.d.ts CHANGED
@@ -5722,22 +5722,35 @@ export declare class MongoChangeStreamError extends MongoRuntimeError {
5722
5722
  }
5723
5723
 
5724
5724
  /**
5725
- * The **MongoClient** class is a class that allows for making Connections to MongoDB.
5726
5725
  * @public
5727
5726
  *
5727
+ * The **MongoClient** class is a class that allows for making Connections to MongoDB.
5728
+ *
5729
+ * **NOTE:** The programmatically provided options take precedence over the URI options.
5730
+ *
5728
5731
  * @remarks
5729
- * The programmatically provided options take precedence over the URI options.
5732
+ *
5733
+ * A MongoClient is the entry point to connecting to a MongoDB server.
5734
+ *
5735
+ * It handles a multitude of features on your application's behalf:
5736
+ * - **Server Host Connection Configuration**: A MongoClient is responsible for reading TLS cert, ca, and crl files if provided.
5737
+ * - **SRV Record Polling**: A "`mongodb+srv`" style connection string is used to have the MongoClient resolve DNS SRV records of all server hostnames which the driver periodically monitors for changes and adjusts its current view of hosts correspondingly.
5738
+ * - **Server Monitoring**: The MongoClient automatically keeps monitoring the health of server nodes in your cluster to reach out to the correct and lowest latency one available.
5739
+ * - **Connection Pooling**: To avoid paying the cost of rebuilding a connection to the server on every operation the MongoClient keeps idle connections preserved for reuse.
5740
+ * - **Session Pooling**: The MongoClient creates logical sessions that enable retryable writes, causal consistency, and transactions. It handles pooling these sessions for reuse in subsequent operations.
5741
+ * - **Cursor Operations**: A MongoClient's cursors use the health monitoring system to send the request for more documents to the same server the query began on.
5742
+ * - **Mongocryptd process**: When using auto encryption, a MongoClient will launch a `mongocryptd` instance for handling encryption if the mongocrypt shared library isn't in use.
5743
+ *
5744
+ * There are many more features of a MongoClient that are not listed above.
5745
+ *
5746
+ * In order to enable these features, a number of asynchronous Node.js resources are established by the driver: Timers, FS Requests, Sockets, etc.
5747
+ * For details on cleanup, please refer to the MongoClient `close()` documentation.
5730
5748
  *
5731
5749
  * @example
5732
5750
  * ```ts
5733
5751
  * import { MongoClient } from 'mongodb';
5734
- *
5735
5752
  * // Enable command monitoring for debugging
5736
- * const client = new MongoClient('mongodb://localhost:27017', { monitorCommands: true });
5737
- *
5738
- * client.on('commandStarted', started => console.log(started));
5739
- * client.db().collection('pets');
5740
- * await client.insertOne({ name: 'spot', kind: 'dog' });
5753
+ * const client = new MongoClient('mongodb://localhost:27017?appName=mflix', { monitorCommands: true });
5741
5754
  * ```
5742
5755
  */
5743
5756
  export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable_2 {
@@ -5794,17 +5807,47 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5794
5807
  connect(): Promise<this>;
5795
5808
  /* Excluded from this release type: _connect */
5796
5809
  /**
5797
- * Cleans up client-side resources used by the MongoClient.
5798
- *
5799
- * This includes:
5800
- *
5801
- * - Closes in-use connections.
5802
- * - Closes all active cursors.
5803
- * - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
5804
- * - aborts in progress transactions if is one related to the session.
5805
- * - Ends all unused sessions server-side.
5806
- * - Closes all remaining idle connections.
5807
- * - Cleans up any resources being used for auto encryption if auto encryption is enabled.
5810
+ * Cleans up resources managed by the MongoClient.
5811
+ *
5812
+ * The close method clears and closes all resources whose lifetimes are managed by the MongoClient.
5813
+ * Please refer to the `MongoClient` class documentation for a high level overview of the client's key features and responsibilities.
5814
+ *
5815
+ * **However,** the close method does not handle the cleanup of resources explicitly created by the user.
5816
+ * Any user-created driver resource with its own `close()` method should be explicitly closed by the user before calling MongoClient.close().
5817
+ * This method is written as a "best effort" attempt to leave behind the least amount of resources server-side when possible.
5818
+ *
5819
+ * The following list defines ideal preconditions and consequent pitfalls if they are not met.
5820
+ * The MongoClient, ClientSession, Cursors and ChangeStreams all support [explicit resource management](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html).
5821
+ * 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.
5822
+ *
5823
+ * The close method performs the following in the order listed:
5824
+ * - Client-side:
5825
+ * - **Close in-use connections**: Any connections that are currently waiting on a response from the server will be closed.
5826
+ * This is performed _first_ to avoid reaching the next step (server-side clean up) and having no available connections to check out.
5827
+ * - _Ideal_: All operations have been awaited or cancelled, and the outcomes, regardless of success or failure, have been processed before closing the client servicing the operation.
5828
+ * - _Pitfall_: When `client.close()` is called and all connections are in use, after closing them, the client must create new connections for cleanup operations, which comes at the cost of new TLS/TCP handshakes and authentication steps.
5829
+ * - Server-side:
5830
+ * - **Close active cursors**: All cursors that haven't been completed will have a `killCursor` operation sent to the server they were initialized on, freeing the server-side resource.
5831
+ * - _Ideal_: Cursors are explicitly closed or completed before `client.close()` is called.
5832
+ * - _Pitfall_: `killCursors` may have to build a new connection if the in-use closure ended all pooled connections.
5833
+ * - **End active sessions**: In-use sessions created with `client.startSession()` or `client.withSession()` or implicitly by the driver will have their `.endSession()` method called.
5834
+ * Contrary to the name of the method, `endSession()` returns the session to the client's pool of sessions rather than end them on the server.
5835
+ * - _Ideal_: Transaction outcomes are awaited and their corresponding explicit sessions are ended before `client.close()` is called.
5836
+ * - _Pitfall_: **This step aborts in-progress transactions**. It is advisable to observe the outcome of a transaction before closing your client.
5837
+ * - **End all pooled sessions**: The `endSessions` command with all session IDs the client has pooled is sent to the server to inform the cluster it can clean them up.
5838
+ * - _Ideal_: No user intervention is expected.
5839
+ * - _Pitfall_: None.
5840
+ *
5841
+ * The remaining shutdown is of the MongoClient resources that are intended to be entirely internal but is documented here as their existence relates to the JS event loop.
5842
+ *
5843
+ * - Client-side (again):
5844
+ * - **Stop all server monitoring**: Connections kept live for detecting cluster changes and roundtrip time measurements are shutdown.
5845
+ * - **Close all pooled connections**: Each server node in the cluster has a corresponding connection pool and all connections in the pool are closed. Any operations waiting to check out a connection will have an error thrown instead of a connection returned.
5846
+ * - **Clear out server selection queue**: Any operations that are in the process of waiting for a server to be selected will have an error thrown instead of a server returned.
5847
+ * - **Close encryption-related resources**: An internal MongoClient created for communicating with `mongocryptd` or other encryption purposes is closed. (Using this same method of course!)
5848
+ *
5849
+ * After the close method completes there should be no MongoClient related resources [ref-ed in Node.js' event loop](https://docs.libuv.org/en/v1.x/handle.html#reference-counting).
5850
+ * This should allow Node.js to exit gracefully if MongoClient resources were the only active handles in the event loop.
5808
5851
  *
5809
5852
  * @param _force - currently an unused flag that has no effect. Defaults to `false`.
5810
5853
  */
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OP_MSG = exports.OP_COMPRESSED = exports.OP_DELETE = exports.OP_QUERY = exports.OP_INSERT = exports.OP_UPDATE = exports.OP_REPLY = exports.MIN_SUPPORTED_QE_SERVER_VERSION = exports.MIN_SUPPORTED_QE_WIRE_VERSION = exports.MAX_SUPPORTED_WIRE_VERSION = exports.MIN_SUPPORTED_WIRE_VERSION = exports.MAX_SUPPORTED_SERVER_VERSION = exports.MIN_SUPPORTED_SERVER_VERSION = void 0;
4
- exports.MIN_SUPPORTED_SERVER_VERSION = '4.0';
4
+ exports.MIN_SUPPORTED_SERVER_VERSION = '4.2';
5
5
  exports.MAX_SUPPORTED_SERVER_VERSION = '8.0';
6
- exports.MIN_SUPPORTED_WIRE_VERSION = 7;
6
+ exports.MIN_SUPPORTED_WIRE_VERSION = 8;
7
7
  exports.MAX_SUPPORTED_WIRE_VERSION = 25;
8
8
  exports.MIN_SUPPORTED_QE_WIRE_VERSION = 21;
9
9
  exports.MIN_SUPPORTED_QE_SERVER_VERSION = '7.0';
@@ -27,22 +27,35 @@ exports.ServerApiVersion = Object.freeze({
27
27
  v1: '1'
28
28
  });
29
29
  /**
30
- * The **MongoClient** class is a class that allows for making Connections to MongoDB.
31
30
  * @public
32
31
  *
32
+ * The **MongoClient** class is a class that allows for making Connections to MongoDB.
33
+ *
34
+ * **NOTE:** The programmatically provided options take precedence over the URI options.
35
+ *
33
36
  * @remarks
34
- * The programmatically provided options take precedence over the URI options.
37
+ *
38
+ * A MongoClient is the entry point to connecting to a MongoDB server.
39
+ *
40
+ * It handles a multitude of features on your application's behalf:
41
+ * - **Server Host Connection Configuration**: A MongoClient is responsible for reading TLS cert, ca, and crl files if provided.
42
+ * - **SRV Record Polling**: A "`mongodb+srv`" style connection string is used to have the MongoClient resolve DNS SRV records of all server hostnames which the driver periodically monitors for changes and adjusts its current view of hosts correspondingly.
43
+ * - **Server Monitoring**: The MongoClient automatically keeps monitoring the health of server nodes in your cluster to reach out to the correct and lowest latency one available.
44
+ * - **Connection Pooling**: To avoid paying the cost of rebuilding a connection to the server on every operation the MongoClient keeps idle connections preserved for reuse.
45
+ * - **Session Pooling**: The MongoClient creates logical sessions that enable retryable writes, causal consistency, and transactions. It handles pooling these sessions for reuse in subsequent operations.
46
+ * - **Cursor Operations**: A MongoClient's cursors use the health monitoring system to send the request for more documents to the same server the query began on.
47
+ * - **Mongocryptd process**: When using auto encryption, a MongoClient will launch a `mongocryptd` instance for handling encryption if the mongocrypt shared library isn't in use.
48
+ *
49
+ * There are many more features of a MongoClient that are not listed above.
50
+ *
51
+ * In order to enable these features, a number of asynchronous Node.js resources are established by the driver: Timers, FS Requests, Sockets, etc.
52
+ * For details on cleanup, please refer to the MongoClient `close()` documentation.
35
53
  *
36
54
  * @example
37
55
  * ```ts
38
56
  * import { MongoClient } from 'mongodb';
39
- *
40
57
  * // Enable command monitoring for debugging
41
- * const client = new MongoClient('mongodb://localhost:27017', { monitorCommands: true });
42
- *
43
- * client.on('commandStarted', started => console.log(started));
44
- * client.db().collection('pets');
45
- * await client.insertOne({ name: 'spot', kind: 'dog' });
58
+ * const client = new MongoClient('mongodb://localhost:27017?appName=mflix', { monitorCommands: true });
46
59
  * ```
47
60
  */
48
61
  class MongoClient extends mongo_types_1.TypedEventEmitter {
@@ -248,17 +261,47 @@ class MongoClient extends mongo_types_1.TypedEventEmitter {
248
261
  return this;
249
262
  }
250
263
  /**
251
- * Cleans up client-side resources used by the MongoClient.
264
+ * Cleans up resources managed by the MongoClient.
265
+ *
266
+ * The close method clears and closes all resources whose lifetimes are managed by the MongoClient.
267
+ * Please refer to the `MongoClient` class documentation for a high level overview of the client's key features and responsibilities.
268
+ *
269
+ * **However,** the close method does not handle the cleanup of resources explicitly created by the user.
270
+ * Any user-created driver resource with its own `close()` method should be explicitly closed by the user before calling MongoClient.close().
271
+ * This method is written as a "best effort" attempt to leave behind the least amount of resources server-side when possible.
272
+ *
273
+ * The following list defines ideal preconditions and consequent pitfalls if they are not met.
274
+ * The MongoClient, ClientSession, Cursors and ChangeStreams all support [explicit resource management](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html).
275
+ * 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.
276
+ *
277
+ * The close method performs the following in the order listed:
278
+ * - Client-side:
279
+ * - **Close in-use connections**: Any connections that are currently waiting on a response from the server will be closed.
280
+ * This is performed _first_ to avoid reaching the next step (server-side clean up) and having no available connections to check out.
281
+ * - _Ideal_: All operations have been awaited or cancelled, and the outcomes, regardless of success or failure, have been processed before closing the client servicing the operation.
282
+ * - _Pitfall_: When `client.close()` is called and all connections are in use, after closing them, the client must create new connections for cleanup operations, which comes at the cost of new TLS/TCP handshakes and authentication steps.
283
+ * - Server-side:
284
+ * - **Close active cursors**: All cursors that haven't been completed will have a `killCursor` operation sent to the server they were initialized on, freeing the server-side resource.
285
+ * - _Ideal_: Cursors are explicitly closed or completed before `client.close()` is called.
286
+ * - _Pitfall_: `killCursors` may have to build a new connection if the in-use closure ended all pooled connections.
287
+ * - **End active sessions**: In-use sessions created with `client.startSession()` or `client.withSession()` or implicitly by the driver will have their `.endSession()` method called.
288
+ * Contrary to the name of the method, `endSession()` returns the session to the client's pool of sessions rather than end them on the server.
289
+ * - _Ideal_: Transaction outcomes are awaited and their corresponding explicit sessions are ended before `client.close()` is called.
290
+ * - _Pitfall_: **This step aborts in-progress transactions**. It is advisable to observe the outcome of a transaction before closing your client.
291
+ * - **End all pooled sessions**: The `endSessions` command with all session IDs the client has pooled is sent to the server to inform the cluster it can clean them up.
292
+ * - _Ideal_: No user intervention is expected.
293
+ * - _Pitfall_: None.
294
+ *
295
+ * The remaining shutdown is of the MongoClient resources that are intended to be entirely internal but is documented here as their existence relates to the JS event loop.
252
296
  *
253
- * This includes:
297
+ * - Client-side (again):
298
+ * - **Stop all server monitoring**: Connections kept live for detecting cluster changes and roundtrip time measurements are shutdown.
299
+ * - **Close all pooled connections**: Each server node in the cluster has a corresponding connection pool and all connections in the pool are closed. Any operations waiting to check out a connection will have an error thrown instead of a connection returned.
300
+ * - **Clear out server selection queue**: Any operations that are in the process of waiting for a server to be selected will have an error thrown instead of a server returned.
301
+ * - **Close encryption-related resources**: An internal MongoClient created for communicating with `mongocryptd` or other encryption purposes is closed. (Using this same method of course!)
254
302
  *
255
- * - Closes in-use connections.
256
- * - Closes all active cursors.
257
- * - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
258
- * - aborts in progress transactions if is one related to the session.
259
- * - Ends all unused sessions server-side.
260
- * - Closes all remaining idle connections.
261
- * - Cleans up any resources being used for auto encryption if auto encryption is enabled.
303
+ * After the close method completes there should be no MongoClient related resources [ref-ed in Node.js' event loop](https://docs.libuv.org/en/v1.x/handle.html#reference-counting).
304
+ * This should allow Node.js to exit gracefully if MongoClient resources were the only active handles in the event loop.
262
305
  *
263
306
  * @param _force - currently an unused flag that has no effect. Defaults to `false`.
264
307
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mongo_client.js","sourceRoot":"","sources":["../src/mongo_client.ts"],"names":[],"mappings":";;;AAAA,2BAAoC;AAIpC,iCAAsF;AACtF,mDAAoG;AAEpG,qEAIuC;AAEvC,qDAAsD;AAKtD,2DAAqE;AACrE,2CAAkD;AAElD,6BAA0C;AAE1C,mCAAoD;AACpD,+EAAyE;AACzE,iDAMwB;AACxB,+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A3kBD,kCA2kBC;AAED,IAAA,iDAA2B,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC"}
package/mongodb.d.ts CHANGED
@@ -5680,22 +5680,35 @@ export declare class MongoChangeStreamError extends MongoRuntimeError {
5680
5680
  }
5681
5681
 
5682
5682
  /**
5683
- * The **MongoClient** class is a class that allows for making Connections to MongoDB.
5684
5683
  * @public
5685
5684
  *
5685
+ * The **MongoClient** class is a class that allows for making Connections to MongoDB.
5686
+ *
5687
+ * **NOTE:** The programmatically provided options take precedence over the URI options.
5688
+ *
5686
5689
  * @remarks
5687
- * The programmatically provided options take precedence over the URI options.
5690
+ *
5691
+ * A MongoClient is the entry point to connecting to a MongoDB server.
5692
+ *
5693
+ * It handles a multitude of features on your application's behalf:
5694
+ * - **Server Host Connection Configuration**: A MongoClient is responsible for reading TLS cert, ca, and crl files if provided.
5695
+ * - **SRV Record Polling**: A "`mongodb+srv`" style connection string is used to have the MongoClient resolve DNS SRV records of all server hostnames which the driver periodically monitors for changes and adjusts its current view of hosts correspondingly.
5696
+ * - **Server Monitoring**: The MongoClient automatically keeps monitoring the health of server nodes in your cluster to reach out to the correct and lowest latency one available.
5697
+ * - **Connection Pooling**: To avoid paying the cost of rebuilding a connection to the server on every operation the MongoClient keeps idle connections preserved for reuse.
5698
+ * - **Session Pooling**: The MongoClient creates logical sessions that enable retryable writes, causal consistency, and transactions. It handles pooling these sessions for reuse in subsequent operations.
5699
+ * - **Cursor Operations**: A MongoClient's cursors use the health monitoring system to send the request for more documents to the same server the query began on.
5700
+ * - **Mongocryptd process**: When using auto encryption, a MongoClient will launch a `mongocryptd` instance for handling encryption if the mongocrypt shared library isn't in use.
5701
+ *
5702
+ * There are many more features of a MongoClient that are not listed above.
5703
+ *
5704
+ * In order to enable these features, a number of asynchronous Node.js resources are established by the driver: Timers, FS Requests, Sockets, etc.
5705
+ * For details on cleanup, please refer to the MongoClient `close()` documentation.
5688
5706
  *
5689
5707
  * @example
5690
5708
  * ```ts
5691
5709
  * import { MongoClient } from 'mongodb';
5692
- *
5693
5710
  * // Enable command monitoring for debugging
5694
- * const client = new MongoClient('mongodb://localhost:27017', { monitorCommands: true });
5695
- *
5696
- * client.on('commandStarted', started => console.log(started));
5697
- * client.db().collection('pets');
5698
- * await client.insertOne({ name: 'spot', kind: 'dog' });
5711
+ * const client = new MongoClient('mongodb://localhost:27017?appName=mflix', { monitorCommands: true });
5699
5712
  * ```
5700
5713
  */
5701
5714
  export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable_2 {
@@ -5747,17 +5760,47 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5747
5760
  connect(): Promise<this>;
5748
5761
  /* Excluded from this release type: _connect */
5749
5762
  /**
5750
- * Cleans up client-side resources used by the MongoClient.
5751
- *
5752
- * This includes:
5753
- *
5754
- * - Closes in-use connections.
5755
- * - Closes all active cursors.
5756
- * - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
5757
- * - aborts in progress transactions if is one related to the session.
5758
- * - Ends all unused sessions server-side.
5759
- * - Closes all remaining idle connections.
5760
- * - Cleans up any resources being used for auto encryption if auto encryption is enabled.
5763
+ * Cleans up resources managed by the MongoClient.
5764
+ *
5765
+ * The close method clears and closes all resources whose lifetimes are managed by the MongoClient.
5766
+ * Please refer to the `MongoClient` class documentation for a high level overview of the client's key features and responsibilities.
5767
+ *
5768
+ * **However,** the close method does not handle the cleanup of resources explicitly created by the user.
5769
+ * Any user-created driver resource with its own `close()` method should be explicitly closed by the user before calling MongoClient.close().
5770
+ * This method is written as a "best effort" attempt to leave behind the least amount of resources server-side when possible.
5771
+ *
5772
+ * The following list defines ideal preconditions and consequent pitfalls if they are not met.
5773
+ * The MongoClient, ClientSession, Cursors and ChangeStreams all support [explicit resource management](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html).
5774
+ * 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.
5775
+ *
5776
+ * The close method performs the following in the order listed:
5777
+ * - Client-side:
5778
+ * - **Close in-use connections**: Any connections that are currently waiting on a response from the server will be closed.
5779
+ * This is performed _first_ to avoid reaching the next step (server-side clean up) and having no available connections to check out.
5780
+ * - _Ideal_: All operations have been awaited or cancelled, and the outcomes, regardless of success or failure, have been processed before closing the client servicing the operation.
5781
+ * - _Pitfall_: When `client.close()` is called and all connections are in use, after closing them, the client must create new connections for cleanup operations, which comes at the cost of new TLS/TCP handshakes and authentication steps.
5782
+ * - Server-side:
5783
+ * - **Close active cursors**: All cursors that haven't been completed will have a `killCursor` operation sent to the server they were initialized on, freeing the server-side resource.
5784
+ * - _Ideal_: Cursors are explicitly closed or completed before `client.close()` is called.
5785
+ * - _Pitfall_: `killCursors` may have to build a new connection if the in-use closure ended all pooled connections.
5786
+ * - **End active sessions**: In-use sessions created with `client.startSession()` or `client.withSession()` or implicitly by the driver will have their `.endSession()` method called.
5787
+ * Contrary to the name of the method, `endSession()` returns the session to the client's pool of sessions rather than end them on the server.
5788
+ * - _Ideal_: Transaction outcomes are awaited and their corresponding explicit sessions are ended before `client.close()` is called.
5789
+ * - _Pitfall_: **This step aborts in-progress transactions**. It is advisable to observe the outcome of a transaction before closing your client.
5790
+ * - **End all pooled sessions**: The `endSessions` command with all session IDs the client has pooled is sent to the server to inform the cluster it can clean them up.
5791
+ * - _Ideal_: No user intervention is expected.
5792
+ * - _Pitfall_: None.
5793
+ *
5794
+ * The remaining shutdown is of the MongoClient resources that are intended to be entirely internal but is documented here as their existence relates to the JS event loop.
5795
+ *
5796
+ * - Client-side (again):
5797
+ * - **Stop all server monitoring**: Connections kept live for detecting cluster changes and roundtrip time measurements are shutdown.
5798
+ * - **Close all pooled connections**: Each server node in the cluster has a corresponding connection pool and all connections in the pool are closed. Any operations waiting to check out a connection will have an error thrown instead of a connection returned.
5799
+ * - **Clear out server selection queue**: Any operations that are in the process of waiting for a server to be selected will have an error thrown instead of a server returned.
5800
+ * - **Close encryption-related resources**: An internal MongoClient created for communicating with `mongocryptd` or other encryption purposes is closed. (Using this same method of course!)
5801
+ *
5802
+ * After the close method completes there should be no MongoClient related resources [ref-ed in Node.js' event loop](https://docs.libuv.org/en/v1.x/handle.html#reference-counting).
5803
+ * This should allow Node.js to exit gracefully if MongoClient resources were the only active handles in the event loop.
5761
5804
  *
5762
5805
  * @param _force - currently an unused flag that has no effect. Defaults to `false`.
5763
5806
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "6.16.0-dev.20250506.sha.6a35701d",
3
+ "version": "6.16.0-dev.20250510.sha.6fe6ccc8",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -1,6 +1,6 @@
1
- export const MIN_SUPPORTED_SERVER_VERSION = '4.0';
1
+ export const MIN_SUPPORTED_SERVER_VERSION = '4.2';
2
2
  export const MAX_SUPPORTED_SERVER_VERSION = '8.0';
3
- export const MIN_SUPPORTED_WIRE_VERSION = 7;
3
+ export const MIN_SUPPORTED_WIRE_VERSION = 8;
4
4
  export const MAX_SUPPORTED_WIRE_VERSION = 25;
5
5
  export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;
6
6
  export const MIN_SUPPORTED_QE_SERVER_VERSION = '7.0';
@@ -347,22 +347,35 @@ export type MongoClientEvents = Pick<TopologyEvents, (typeof MONGO_CLIENT_EVENTS
347
347
  };
348
348
 
349
349
  /**
350
- * The **MongoClient** class is a class that allows for making Connections to MongoDB.
351
350
  * @public
352
351
  *
352
+ * The **MongoClient** class is a class that allows for making Connections to MongoDB.
353
+ *
354
+ * **NOTE:** The programmatically provided options take precedence over the URI options.
355
+ *
353
356
  * @remarks
354
- * The programmatically provided options take precedence over the URI options.
357
+ *
358
+ * A MongoClient is the entry point to connecting to a MongoDB server.
359
+ *
360
+ * It handles a multitude of features on your application's behalf:
361
+ * - **Server Host Connection Configuration**: A MongoClient is responsible for reading TLS cert, ca, and crl files if provided.
362
+ * - **SRV Record Polling**: A "`mongodb+srv`" style connection string is used to have the MongoClient resolve DNS SRV records of all server hostnames which the driver periodically monitors for changes and adjusts its current view of hosts correspondingly.
363
+ * - **Server Monitoring**: The MongoClient automatically keeps monitoring the health of server nodes in your cluster to reach out to the correct and lowest latency one available.
364
+ * - **Connection Pooling**: To avoid paying the cost of rebuilding a connection to the server on every operation the MongoClient keeps idle connections preserved for reuse.
365
+ * - **Session Pooling**: The MongoClient creates logical sessions that enable retryable writes, causal consistency, and transactions. It handles pooling these sessions for reuse in subsequent operations.
366
+ * - **Cursor Operations**: A MongoClient's cursors use the health monitoring system to send the request for more documents to the same server the query began on.
367
+ * - **Mongocryptd process**: When using auto encryption, a MongoClient will launch a `mongocryptd` instance for handling encryption if the mongocrypt shared library isn't in use.
368
+ *
369
+ * There are many more features of a MongoClient that are not listed above.
370
+ *
371
+ * In order to enable these features, a number of asynchronous Node.js resources are established by the driver: Timers, FS Requests, Sockets, etc.
372
+ * For details on cleanup, please refer to the MongoClient `close()` documentation.
355
373
  *
356
374
  * @example
357
375
  * ```ts
358
376
  * import { MongoClient } from 'mongodb';
359
- *
360
377
  * // Enable command monitoring for debugging
361
- * const client = new MongoClient('mongodb://localhost:27017', { monitorCommands: true });
362
- *
363
- * client.on('commandStarted', started => console.log(started));
364
- * client.db().collection('pets');
365
- * await client.insertOne({ name: 'spot', kind: 'dog' });
378
+ * const client = new MongoClient('mongodb://localhost:27017?appName=mflix', { monitorCommands: true });
366
379
  * ```
367
380
  */
368
381
  export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable {
@@ -641,17 +654,47 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
641
654
  }
642
655
 
643
656
  /**
644
- * Cleans up client-side resources used by the MongoClient.
657
+ * Cleans up resources managed by the MongoClient.
658
+ *
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.
661
+ *
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().
664
+ * This method is written as a "best effort" attempt to leave behind the least amount of resources server-side when possible.
665
+ *
666
+ * 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.
669
+ *
670
+ * The close method performs the following in the order listed:
671
+ * - Client-side:
672
+ * - **Close in-use connections**: Any connections that are currently waiting on a response from the server will be closed.
673
+ * This is performed _first_ to avoid reaching the next step (server-side clean up) and having no available connections to check out.
674
+ * - _Ideal_: All operations have been awaited or cancelled, and the outcomes, regardless of success or failure, have been processed before closing the client servicing the operation.
675
+ * - _Pitfall_: When `client.close()` is called and all connections are in use, after closing them, the client must create new connections for cleanup operations, which comes at the cost of new TLS/TCP handshakes and authentication steps.
676
+ * - Server-side:
677
+ * - **Close active cursors**: All cursors that haven't been completed will have a `killCursor` operation sent to the server they were initialized on, freeing the server-side resource.
678
+ * - _Ideal_: Cursors are explicitly closed or completed before `client.close()` is called.
679
+ * - _Pitfall_: `killCursors` may have to build a new connection if the in-use closure ended all pooled connections.
680
+ * - **End active sessions**: In-use sessions created with `client.startSession()` or `client.withSession()` or implicitly by the driver will have their `.endSession()` method called.
681
+ * Contrary to the name of the method, `endSession()` returns the session to the client's pool of sessions rather than end them on the server.
682
+ * - _Ideal_: Transaction outcomes are awaited and their corresponding explicit sessions are ended before `client.close()` is called.
683
+ * - _Pitfall_: **This step aborts in-progress transactions**. It is advisable to observe the outcome of a transaction before closing your client.
684
+ * - **End all pooled sessions**: The `endSessions` command with all session IDs the client has pooled is sent to the server to inform the cluster it can clean them up.
685
+ * - _Ideal_: No user intervention is expected.
686
+ * - _Pitfall_: None.
687
+ *
688
+ * The remaining shutdown is of the MongoClient resources that are intended to be entirely internal but is documented here as their existence relates to the JS event loop.
645
689
  *
646
- * This includes:
690
+ * - Client-side (again):
691
+ * - **Stop all server monitoring**: Connections kept live for detecting cluster changes and roundtrip time measurements are shutdown.
692
+ * - **Close all pooled connections**: Each server node in the cluster has a corresponding connection pool and all connections in the pool are closed. Any operations waiting to check out a connection will have an error thrown instead of a connection returned.
693
+ * - **Clear out server selection queue**: Any operations that are in the process of waiting for a server to be selected will have an error thrown instead of a server returned.
694
+ * - **Close encryption-related resources**: An internal MongoClient created for communicating with `mongocryptd` or other encryption purposes is closed. (Using this same method of course!)
647
695
  *
648
- * - Closes in-use connections.
649
- * - Closes all active cursors.
650
- * - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
651
- * - aborts in progress transactions if is one related to the session.
652
- * - Ends all unused sessions server-side.
653
- * - Closes all remaining idle connections.
654
- * - Cleans up any resources being used for auto encryption if auto encryption is enabled.
696
+ * After the close method completes there should be no MongoClient related resources [ref-ed in Node.js' event loop](https://docs.libuv.org/en/v1.x/handle.html#reference-counting).
697
+ * This should allow Node.js to exit gracefully if MongoClient resources were the only active handles in the event loop.
655
698
  *
656
699
  * @param _force - currently an unused flag that has no effect. Defaults to `false`.
657
700
  */