mongodb 6.20.0-dev.20251008.sha.cfbada66 → 6.20.0-dev.20251010.sha.c5f74abe

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.
Files changed (41) hide show
  1. package/lib/change_stream.js +5 -4
  2. package/lib/change_stream.js.map +1 -1
  3. package/lib/cmap/connect.js +1 -1
  4. package/lib/cmap/connect.js.map +1 -1
  5. package/lib/cmap/connection.js.map +1 -1
  6. package/lib/cmap/connection_pool.js +4 -4
  7. package/lib/cmap/connection_pool.js.map +1 -1
  8. package/lib/cmap/handshake/client_metadata.js +7 -5
  9. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  10. package/lib/cursor/abstract_cursor.js +5 -4
  11. package/lib/cursor/abstract_cursor.js.map +1 -1
  12. package/lib/index.js +2 -4
  13. package/lib/index.js.map +1 -1
  14. package/lib/mongo_client.js +34 -27
  15. package/lib/mongo_client.js.map +1 -1
  16. package/lib/operations/aggregate.js +0 -3
  17. package/lib/operations/aggregate.js.map +1 -1
  18. package/lib/sdam/topology.js +1 -4
  19. package/lib/sdam/topology.js.map +1 -1
  20. package/lib/sessions.js +5 -4
  21. package/lib/sessions.js.map +1 -1
  22. package/mongodb.d.ts +58 -82
  23. package/package.json +2 -3
  24. package/src/change_stream.ts +1 -7
  25. package/src/cmap/connect.ts +1 -1
  26. package/src/cmap/connection.ts +1 -2
  27. package/src/cmap/connection_pool.ts +4 -4
  28. package/src/cmap/handshake/client_metadata.ts +18 -13
  29. package/src/cursor/abstract_cursor.ts +1 -7
  30. package/src/index.ts +0 -2
  31. package/src/mongo_client.ts +38 -62
  32. package/src/operations/aggregate.ts +0 -6
  33. package/src/sdam/topology.ts +2 -7
  34. package/src/sessions.ts +1 -7
  35. package/lib/beta.d.ts +0 -9094
  36. package/lib/beta.js +0 -21
  37. package/lib/beta.js.map +0 -1
  38. package/lib/resource_management.js +0 -58
  39. package/lib/resource_management.js.map +0 -1
  40. package/src/beta.ts +0 -22
  41. package/src/resource_management.ts +0 -74
package/mongodb.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare type Abortable = {
69
69
  };
70
70
 
71
71
  /** @public */
72
- export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> implements AsyncDisposable_2 {
72
+ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> implements AsyncDisposable {
73
73
  /* Excluded from this release type: cursorId */
74
74
  /* Excluded from this release type: cursorSession */
75
75
  /* Excluded from this release type: selectedServer */
@@ -114,8 +114,11 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
114
114
  */
115
115
  get killed(): boolean;
116
116
  get loadBalanced(): boolean;
117
- /* Excluded from this release type: [Symbol.asyncDispose] */
118
- /* Excluded from this release type: asyncDispose */
117
+ /**
118
+ * @experimental
119
+ * An alias for {@link AbstractCursor.close|AbstractCursor.close()}.
120
+ */
121
+ [Symbol.asyncDispose](): Promise<void>;
119
122
  /** Adds cursor to client's tracking so it will be closed by MongoClient.close() */
120
123
  private trackCursor;
121
124
  /** Returns current buffered documents length */
@@ -628,15 +631,6 @@ export declare type ArrayOperator<Type> = {
628
631
  $sort?: Sort;
629
632
  };
630
633
 
631
- /**
632
- * @public
633
- */
634
- declare interface AsyncDisposable_2 {
635
- /* Excluded from this release type: [Symbol.asyncDispose] */
636
- /* Excluded from this release type: asyncDispose */
637
- }
638
- export { AsyncDisposable_2 as AsyncDisposable }
639
-
640
634
  /** @public */
641
635
  export declare interface Auth {
642
636
  /** The username for auth */
@@ -1171,9 +1165,12 @@ export declare type Callback<T = any> = (error?: AnyError, result?: T) => void;
1171
1165
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
1172
1166
  * @public
1173
1167
  */
1174
- export declare class ChangeStream<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> implements AsyncDisposable_2 {
1175
- /* Excluded from this release type: [Symbol.asyncDispose] */
1176
- /* Excluded from this release type: asyncDispose */
1168
+ export declare class ChangeStream<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> implements AsyncDisposable {
1169
+ /**
1170
+ * @experimental
1171
+ * An alias for {@link ChangeStream.close|ChangeStream.close()}.
1172
+ */
1173
+ [Symbol.asyncDispose](): Promise<void>;
1177
1174
  pipeline: Document[];
1178
1175
  /**
1179
1176
  * @remarks WriteConcern can still be present on the options because
@@ -2272,35 +2269,7 @@ export declare interface ClientInsertOneResult {
2272
2269
  insertedId: any;
2273
2270
  }
2274
2271
 
2275
- /**
2276
- * @public
2277
- * @deprecated This interface will be made internal in the next major release.
2278
- * @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#hello-command
2279
- */
2280
- export declare interface ClientMetadata {
2281
- driver: {
2282
- name: string;
2283
- version: string;
2284
- };
2285
- os: {
2286
- type: string;
2287
- name?: NodeJS.Platform;
2288
- architecture?: string;
2289
- version?: string;
2290
- };
2291
- platform: string;
2292
- application?: {
2293
- name: string;
2294
- };
2295
- /** FaaS environment information */
2296
- env?: {
2297
- name: 'aws.lambda' | 'gcp.func' | 'azure.func' | 'vercel';
2298
- timeout_sec?: Int32;
2299
- memory_mb?: Int32;
2300
- region?: string;
2301
- url?: string;
2302
- };
2303
- }
2272
+ /* Excluded from this release type: ClientMetadata */
2304
2273
 
2305
2274
  /** @public */
2306
2275
  export declare interface ClientReplaceOneModel<TSchema> extends ClientWriteModel {
@@ -2328,7 +2297,7 @@ export declare interface ClientReplaceOneModel<TSchema> extends ClientWriteModel
2328
2297
  * NOTE: not meant to be instantiated directly.
2329
2298
  * @public
2330
2299
  */
2331
- export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents> implements AsyncDisposable_2 {
2300
+ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents> implements AsyncDisposable {
2332
2301
  /* Excluded from this release type: client */
2333
2302
  /* Excluded from this release type: sessionPool */
2334
2303
  hasEnded: boolean;
@@ -2371,8 +2340,11 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2371
2340
  * @param options - Optional settings. Currently reserved for future use
2372
2341
  */
2373
2342
  endSession(options?: EndSessionOptions): Promise<void>;
2374
- /* Excluded from this release type: [Symbol.asyncDispose] */
2375
- /* Excluded from this release type: asyncDispose */
2343
+ /**
2344
+ * @experimental
2345
+ * An alias for {@link ClientSession.endSession|ClientSession.endSession()}.
2346
+ */
2347
+ [Symbol.asyncDispose](): Promise<void>;
2376
2348
  /**
2377
2349
  * Advances the operationTime for a ClientSession.
2378
2350
  *
@@ -3405,8 +3377,6 @@ export declare type CompressorName = keyof typeof Compressor;
3405
3377
  /** @public */
3406
3378
  export declare type Condition<T> = AlternativeType<T> | FilterOperators<AlternativeType<T>>;
3407
3379
 
3408
- /* Excluded from this release type: configureExplicitResourceManagement */
3409
-
3410
3380
  /* Excluded from this release type: Connection */
3411
3381
 
3412
3382
  /* Excluded from this release type: CONNECTION_CHECK_OUT_FAILED */
@@ -3548,8 +3518,7 @@ export declare interface ConnectionOptions extends SupportedNodeConnectionOption
3548
3518
  noDelay?: boolean;
3549
3519
  socketTimeoutMS?: number;
3550
3520
  /* Excluded from this release type: cancellationToken */
3551
- metadata: ClientMetadata;
3552
- /* Excluded from this release type: extendedMetadata */
3521
+ /* Excluded from this release type: metadata */
3553
3522
  /* Excluded from this release type: mongoLogger */
3554
3523
  }
3555
3524
 
@@ -5716,7 +5685,7 @@ export declare class MongoChangeStreamError extends MongoRuntimeError {
5716
5685
  * const client = new MongoClient('mongodb://localhost:27017?appName=mflix', { monitorCommands: true });
5717
5686
  * ```
5718
5687
  */
5719
- export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable_2 {
5688
+ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable {
5720
5689
  /* Excluded from this release type: s */
5721
5690
  /* Excluded from this release type: topology */
5722
5691
  /* Excluded from this release type: mongoLogger */
@@ -5725,11 +5694,16 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5725
5694
  /**
5726
5695
  * The consolidate, parsed, transformed and merged options.
5727
5696
  */
5728
- readonly options: Readonly<Omit<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert' | 'driverInfo' | 'additionalDriverInfo' | 'metadata' | 'extendedMetadata'>> & Pick<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert' | 'driverInfo' | 'additionalDriverInfo' | 'metadata' | 'extendedMetadata'>;
5697
+ readonly options: Readonly<Omit<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert' | 'driverInfo'>> & Pick<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert' | 'driverInfo'> & {
5698
+ /* Excluded from this release type: metadata */
5699
+ };
5729
5700
  private driverInfoList;
5730
5701
  constructor(url: string, options?: MongoClientOptions);
5731
- /* Excluded from this release type: [Symbol.asyncDispose] */
5732
- /* Excluded from this release type: asyncDispose */
5702
+ /**
5703
+ * @experimental
5704
+ * An alias for {@link MongoClient.close|MongoClient.close()}.
5705
+ */
5706
+ [Symbol.asyncDispose](): Promise<void>;
5733
5707
  /**
5734
5708
  * Append metadata to the client metadata after instantiation.
5735
5709
  * @param driverInfo - Information about the application or library.
@@ -5753,20 +5727,13 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5753
5727
  */
5754
5728
  bulkWrite<SchemaMap extends Record<string, Document> = Record<string, Document>>(models: ReadonlyArray<ClientBulkWriteModel<SchemaMap>>, options?: ClientBulkWriteOptions): Promise<ClientBulkWriteResult>;
5755
5729
  /**
5756
- * Connect to MongoDB using a url
5757
- *
5758
- * @remarks
5759
- * Calling `connect` is optional since the first operation you perform will call `connect` if it's needed.
5760
- * `timeoutMS` will bound the time any operation can take before throwing a timeout error.
5761
- * However, when the operation being run is automatically connecting your `MongoClient` the `timeoutMS` will not apply to the time taken to connect the MongoClient.
5762
- * This means the time to setup the `MongoClient` does not count against `timeoutMS`.
5763
- * If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
5730
+ * An optional method to verify a handful of assumptions that are generally useful at application boot-time before using a MongoClient.
5731
+ * For detailed information about the connect process see the MongoClient.connect static method documentation.
5764
5732
  *
5765
- * @remarks
5766
- * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5767
- * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5733
+ * @param url - The MongoDB connection string (supports `mongodb://` and `mongodb+srv://` schemes)
5734
+ * @param options - Optional configuration options for the client
5768
5735
  *
5769
- * @see docs.mongodb.org/manual/reference/connection-string/
5736
+ * @see https://www.mongodb.com/docs/manual/reference/connection-string/
5770
5737
  */
5771
5738
  connect(): Promise<this>;
5772
5739
  /* Excluded from this release type: _connect */
@@ -5825,21 +5792,35 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5825
5792
  */
5826
5793
  db(dbName?: string, options?: DbOptions): Db;
5827
5794
  /**
5828
- * Connect to MongoDB using a url
5795
+ * Creates a new MongoClient instance and immediately connects it to MongoDB.
5796
+ * This convenience method combines `new MongoClient(url, options)` and `client.connect()` in a single step.
5797
+ *
5798
+ * Connect can be helpful to detect configuration issues early by validating:
5799
+ * - **DNS Resolution**: Verifies that SRV records and hostnames in the connection string resolve DNS entries
5800
+ * - **Network Connectivity**: Confirms that host addresses are reachable and ports are open
5801
+ * - **TLS Configuration**: Validates SSL/TLS certificates, CA files, and encryption settings are correct
5802
+ * - **Authentication**: Verifies that provided credentials are valid
5803
+ * - **Server Compatibility**: Ensures the MongoDB server version is supported by this driver version
5804
+ * - **Load Balancer Setup**: For load-balanced deployments, confirms the service is properly configured
5805
+ *
5806
+ * @returns A promise that resolves to the same MongoClient instance once connected
5829
5807
  *
5830
5808
  * @remarks
5831
- * Calling `connect` is optional since the first operation you perform will call `connect` if it's needed.
5832
- * `timeoutMS` will bound the time any operation can take before throwing a timeout error.
5833
- * However, when the operation being run is automatically connecting your `MongoClient` the `timeoutMS` will not apply to the time taken to connect the MongoClient.
5834
- * This means the time to setup the `MongoClient` does not count against `timeoutMS`.
5835
- * If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
5809
+ * **Connection is Optional:** Calling `connect` is optional since any operation method (`find`, `insertOne`, etc.)
5810
+ * will automatically perform these same validation steps if the client is not already connected.
5811
+ * However, explicitly calling `connect` can make sense for:
5812
+ * - **Fail-fast Error Detection**: Non-transient connection issues (hostname unresolved, port refused connection) are discovered immediately rather than during your first operation
5813
+ * - **Predictable Performance**: Eliminates first connection overhead from your first database operation
5836
5814
  *
5837
5815
  * @remarks
5838
- * The programmatically provided options take precedence over the URI options.
5816
+ * **Connection Pooling Impact:** Calling `connect` will populate the connection pool with one connection
5817
+ * to a server selected by the client's configured `readPreference` (defaults to primary).
5839
5818
  *
5840
5819
  * @remarks
5841
- * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5842
- * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5820
+ * **Timeout Behavior:** When using `timeoutMS`, the connection establishment time does not count against
5821
+ * the timeout for subsequent operations. This means `connect` runs without a `timeoutMS` limit, while
5822
+ * your database operations will still respect the configured timeout. If you need predictable operation
5823
+ * timing with `timeoutMS`, call `connect` explicitly before performing operations.
5843
5824
  *
5844
5825
  * @see https://www.mongodb.com/docs/manual/reference/connection-string/
5845
5826
  */
@@ -6980,12 +6961,7 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
6980
6961
  compressors: CompressorName[];
6981
6962
  writeConcern: WriteConcern;
6982
6963
  dbName: string;
6983
- /** @deprecated - Will be made internal in a future major release. */
6984
- metadata: ClientMetadata;
6985
- /** @deprecated - Will be made internal in a future major release. */
6986
- extendedMetadata: Promise<Document>;
6987
- /** @deprecated - Will be made internal in a future major release. */
6988
- additionalDriverInfo: DriverInfo[];
6964
+ /* Excluded from this release type: metadata */
6989
6965
  /* Excluded from this release type: autoEncrypter */
6990
6966
  /* Excluded from this release type: tokenCache */
6991
6967
  proxyHost?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "6.20.0-dev.20251008.sha.cfbada66",
3
+ "version": "6.20.0-dev.20251010.sha.c5f74abe",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -124,7 +124,7 @@
124
124
  "scripts": {
125
125
  "build:evergreen": "node .evergreen/generate_evergreen_tasks.js",
126
126
  "build:ts": "node ./node_modules/typescript/bin/tsc",
127
- "build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs && ESLINT_USE_FLAT_CONFIG=false eslint --no-ignore --fix mongodb.d.ts lib/beta.d.ts",
127
+ "build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs && ESLINT_USE_FLAT_CONFIG=false eslint --no-ignore --fix mongodb.d.ts",
128
128
  "build:docs": "./etc/docs/build.ts",
129
129
  "build:typedoc": "typedoc",
130
130
  "build:nightly": "node ./.github/scripts/nightly.mjs",
@@ -143,7 +143,6 @@
143
143
  "check:unit": "nyc mocha test/unit",
144
144
  "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
145
145
  "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts",
146
- "check:resource-management": "nyc mocha --config test/manual/mocharc.js test/manual/resource_management.test.ts",
147
146
  "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts",
148
147
  "check:aws": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts",
149
148
  "check:oidc-auth": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/auth.spec.test.ts",
@@ -18,7 +18,6 @@ import { MongoClient } from './mongo_client';
18
18
  import { type InferIdType, TypedEventEmitter } from './mongo_types';
19
19
  import type { AggregateOptions } from './operations/aggregate';
20
20
  import type { OperationParent } from './operations/command';
21
- import { type AsyncDisposable, configureResourceManagement } from './resource_management';
22
21
  import type { ServerSessionId } from './sessions';
23
22
  import { CSOTTimeoutContext, type TimeoutContext } from './timeout';
24
23
  import { filterOptions, getTopology, type MongoDBNamespace, squashError } from './utils';
@@ -574,13 +573,10 @@ export class ChangeStream<
574
573
  implements AsyncDisposable
575
574
  {
576
575
  /**
577
- * @beta
578
576
  * @experimental
579
577
  * An alias for {@link ChangeStream.close|ChangeStream.close()}.
580
578
  */
581
- declare [Symbol.asyncDispose]: () => Promise<void>;
582
- /** @internal */
583
- async asyncDispose() {
579
+ async [Symbol.asyncDispose]() {
584
580
  await this.close();
585
581
  }
586
582
 
@@ -1090,5 +1086,3 @@ export class ChangeStream<
1090
1086
  }
1091
1087
  }
1092
1088
  }
1093
-
1094
- configureResourceManagement(ChangeStream.prototype);
@@ -222,7 +222,7 @@ export async function prepareHandshakeDocument(
222
222
  const options = authContext.options;
223
223
  const compressors = options.compressors ? options.compressors : [];
224
224
  const { serverApi } = authContext.connection;
225
- const clientMetadata: Document = await options.extendedMetadata;
225
+ const clientMetadata: Document = await options.metadata;
226
226
 
227
227
  const handshakeDoc: HandshakeDocument = {
228
228
  [serverApi?.version || options.loadBalanced === true ? 'hello' : LEGACY_HELLO_COMMAND]: 1,
@@ -140,9 +140,8 @@ export interface ConnectionOptions
140
140
  socketTimeoutMS?: number;
141
141
  /** @internal */
142
142
  cancellationToken?: CancellationToken;
143
- metadata: ClientMetadata;
144
143
  /** @internal */
145
- extendedMetadata: Promise<Document>;
144
+ metadata: Promise<ClientMetadata>;
146
145
  /** @internal */
147
146
  mongoLogger?: MongoLogger | undefined;
148
147
  }
@@ -601,9 +601,9 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
601
601
  }
602
602
 
603
603
  private createConnection(callback: Callback<Connection>) {
604
- // Note that metadata and extendedMetadata may have changed on the client but have
605
- // been frozen here, so we pull the extendedMetadata promise always from the client
606
- // no mattter what options were set at the construction of the pool.
604
+ // Note that metadata may have changed on the client but have
605
+ // been frozen here, so we pull the metadata promise always from the client
606
+ // no matter what options were set at the construction of the pool.
607
607
  const connectOptions: ConnectionOptions = {
608
608
  ...this.options,
609
609
  id: this.connectionCounter.next().value,
@@ -611,7 +611,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
611
611
  cancellationToken: this.cancellationToken,
612
612
  mongoLogger: this.mongoLogger,
613
613
  authProviders: this.server.topology.client.s.authProviders,
614
- extendedMetadata: this.server.topology.client.options.extendedMetadata
614
+ metadata: this.server.topology.client.options.metadata
615
615
  };
616
616
 
617
617
  this.pending++;
@@ -27,8 +27,7 @@ export function isDriverInfoEqual(info1: DriverInfo, info2: DriverInfo): boolean
27
27
  }
28
28
 
29
29
  /**
30
- * @public
31
- * @deprecated This interface will be made internal in the next major release.
30
+ * @internal
32
31
  * @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#hello-command
33
32
  */
34
33
  export interface ClientMetadata {
@@ -48,11 +47,14 @@ export interface ClientMetadata {
48
47
  };
49
48
  /** FaaS environment information */
50
49
  env?: {
51
- name: 'aws.lambda' | 'gcp.func' | 'azure.func' | 'vercel';
50
+ name?: 'aws.lambda' | 'gcp.func' | 'azure.func' | 'vercel';
52
51
  timeout_sec?: Int32;
53
52
  memory_mb?: Int32;
54
53
  region?: string;
55
- url?: string;
54
+ container?: {
55
+ runtime?: string;
56
+ orchestrator?: string;
57
+ };
56
58
  };
57
59
  }
58
60
 
@@ -103,10 +105,10 @@ type MakeClientMetadataOptions = Pick<MongoOptions, 'appName'>;
103
105
  * 3. Omit the `env` document entirely.
104
106
  * 4. Truncate `platform`. -- special we do not truncate this field
105
107
  */
106
- export function makeClientMetadata(
108
+ export async function makeClientMetadata(
107
109
  driverInfoList: DriverInfo[],
108
110
  { appName = '' }: MakeClientMetadataOptions
109
- ): ClientMetadata {
111
+ ): Promise<ClientMetadata> {
110
112
  const metadataDocument = new LimitedSizeDocument(512);
111
113
 
112
114
  // Add app name first, it must be sent
@@ -178,19 +180,21 @@ export function makeClientMetadata(
178
180
  }
179
181
  }
180
182
  }
181
- return metadataDocument.toObject() as ClientMetadata;
183
+ return await addContainerMetadata(metadataDocument.toObject() as ClientMetadata);
182
184
  }
183
185
 
184
186
  let dockerPromise: Promise<boolean>;
187
+ type ContainerMetadata = NonNullable<NonNullable<ClientMetadata['env']>['container']>;
185
188
  /** @internal */
186
- async function getContainerMetadata() {
187
- const containerMetadata: Record<string, any> = {};
189
+ async function getContainerMetadata(): Promise<ContainerMetadata> {
188
190
  dockerPromise ??= fileIsAccessible('/.dockerenv');
189
191
  const isDocker = await dockerPromise;
190
192
 
191
193
  const { KUBERNETES_SERVICE_HOST = '' } = process.env;
192
194
  const isKubernetes = KUBERNETES_SERVICE_HOST.length > 0 ? true : false;
193
195
 
196
+ const containerMetadata: ContainerMetadata = {};
197
+
194
198
  if (isDocker) containerMetadata.runtime = 'docker';
195
199
  if (isKubernetes) containerMetadata.orchestrator = 'kubernetes';
196
200
 
@@ -202,15 +206,16 @@ async function getContainerMetadata() {
202
206
  * Re-add each metadata value.
203
207
  * Attempt to add new env container metadata, but keep old data if it does not fit.
204
208
  */
205
- export async function addContainerMetadata(
206
- originalMetadata: ClientMetadata
207
- ): Promise<ClientMetadata> {
209
+ async function addContainerMetadata(originalMetadata: ClientMetadata): Promise<ClientMetadata> {
208
210
  const containerMetadata = await getContainerMetadata();
209
211
  if (Object.keys(containerMetadata).length === 0) return originalMetadata;
210
212
 
211
213
  const extendedMetadata = new LimitedSizeDocument(512);
212
214
 
213
- const extendedEnvMetadata = { ...originalMetadata?.env, container: containerMetadata };
215
+ const extendedEnvMetadata: NonNullable<ClientMetadata['env']> = {
216
+ ...originalMetadata?.env,
217
+ container: containerMetadata
218
+ };
214
219
 
215
220
  for (const [key, val] of Object.entries(originalMetadata)) {
216
221
  if (key !== 'env') {
@@ -18,7 +18,6 @@ import { GetMoreOperation } from '../operations/get_more';
18
18
  import { KillCursorsOperation } from '../operations/kill_cursors';
19
19
  import { ReadConcern, type ReadConcernLike } from '../read_concern';
20
20
  import { ReadPreference, type ReadPreferenceLike } from '../read_preference';
21
- import { type AsyncDisposable, configureResourceManagement } from '../resource_management';
22
21
  import type { Server } from '../sdam/server';
23
22
  import { type ClientSession, maybeClearPinnedConnection } from '../sessions';
24
23
  import { type CSOTTimeoutContext, type Timeout, TimeoutContext } from '../timeout';
@@ -437,13 +436,10 @@ export abstract class AbstractCursor<
437
436
  }
438
437
 
439
438
  /**
440
- * @beta
441
439
  * @experimental
442
440
  * An alias for {@link AbstractCursor.close|AbstractCursor.close()}.
443
441
  */
444
- declare [Symbol.asyncDispose]: () => Promise<void>;
445
- /** @internal */
446
- async asyncDispose() {
442
+ async [Symbol.asyncDispose]() {
447
443
  await this.close();
448
444
  }
449
445
 
@@ -1223,8 +1219,6 @@ class ReadableCursorStream extends Readable {
1223
1219
  }
1224
1220
  }
1225
1221
 
1226
- configureResourceManagement(AbstractCursor.prototype);
1227
-
1228
1222
  /**
1229
1223
  * @internal
1230
1224
  * The cursor timeout context is a wrapper around a timeout context
package/src/index.ts CHANGED
@@ -87,7 +87,6 @@ export {
87
87
  MongoWriteConcernError,
88
88
  WriteConcernErrorResult
89
89
  } from './error';
90
- export { configureExplicitResourceManagement } from './resource_management';
91
90
  export {
92
91
  AbstractCursor,
93
92
  // Actual driver classes exported
@@ -564,7 +563,6 @@ export type {
564
563
  ReadPreferenceLikeOptions,
565
564
  ReadPreferenceOptions
566
565
  } from './read_preference';
567
- export type { AsyncDisposable } from './resource_management';
568
566
  export type { ClusterTime } from './sdam/common';
569
567
  export type {
570
568
  Monitor,