mongodb 6.8.0-dev.20240905.sha.65e0e15c → 6.8.1
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/README.md +1 -14
- package/lib/bson.js +13 -4
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +21 -16
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +8 -10
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +3 -14
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +7 -25
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/crypto_callbacks.js +6 -6
- package/lib/client-side-encryption/crypto_callbacks.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +5 -9
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/client-side-encryption/providers/aws.js +2 -1
- package/lib/client-side-encryption/providers/aws.js.map +1 -1
- package/lib/client-side-encryption/providers/azure.js +5 -5
- package/lib/client-side-encryption/providers/azure.js.map +1 -1
- package/lib/client-side-encryption/providers/gcp.js +2 -1
- package/lib/client-side-encryption/providers/gcp.js.map +1 -1
- package/lib/client-side-encryption/providers/index.js +3 -2
- package/lib/client-side-encryption/providers/index.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +4 -9
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +4 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +3 -2
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +5 -62
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +7 -9
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +5 -3
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +9 -11
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -7
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +5 -5
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/metrics.js +1 -1
- package/lib/cmap/metrics.js.map +1 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +5 -5
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/cmap/wire_protocol/on_data.js +2 -1
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js +3 -12
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +15 -6
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +3 -2
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +5 -10
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +16 -25
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +2 -2
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +4 -4
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +1 -1
- package/lib/db.js.map +1 -1
- package/lib/deps.js +8 -16
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +14 -19
- package/lib/error.js.map +1 -1
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +4 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +1 -1
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +4 -0
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +1 -15
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_logger.js +8 -8
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +0 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +0 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/collections.js.map +1 -1
- package/lib/operations/command.js +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +2 -2
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +109 -111
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +8 -2
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js +5 -5
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +2 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_concern.js.map +1 -1
- package/lib/read_preference.js +1 -1
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/common.js +3 -3
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/monitor.js +5 -1
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +2 -2
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +3 -3
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -5
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +3 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +1 -1
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +218 -221
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +3 -2
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +1 -0
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js +2 -2
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +51 -49
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js +2 -2
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +143 -146
- package/package.json +28 -27
- package/src/bson.ts +13 -1
- package/src/bulk/common.ts +18 -18
- package/src/change_stream.ts +15 -33
- package/src/client-side-encryption/auto_encrypter.ts +82 -18
- package/src/client-side-encryption/client_encryption.ts +54 -51
- package/src/client-side-encryption/mongocryptd_manager.ts +6 -10
- package/src/client-side-encryption/state_machine.ts +6 -28
- package/src/cmap/auth/gssapi.ts +1 -1
- package/src/cmap/auth/mongodb_aws.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
- package/src/cmap/commands.ts +5 -70
- package/src/cmap/connect.ts +1 -3
- package/src/cmap/connection.ts +4 -3
- package/src/cmap/connection_pool.ts +9 -17
- package/src/cmap/connection_pool_events.ts +2 -34
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/constants.ts +2 -2
- package/src/cmap/wire_protocol/on_demand/document.ts +14 -18
- package/src/cmap/wire_protocol/responses.ts +23 -5
- package/src/cmap/wire_protocol/shared.ts +2 -1
- package/src/collection.ts +15 -16
- package/src/connection_string.ts +2 -8
- package/src/constants.ts +0 -1
- package/src/cursor/abstract_cursor.ts +28 -42
- package/src/cursor/aggregation_cursor.ts +5 -7
- package/src/cursor/find_cursor.ts +1 -1
- package/src/deps.ts +1 -8
- package/src/error.ts +14 -33
- package/src/gridfs/download.ts +4 -28
- package/src/gridfs/upload.ts +6 -1
- package/src/index.ts +6 -6
- package/src/mongo_client.ts +3 -25
- package/src/mongo_logger.ts +3 -5
- package/src/mongo_types.ts +68 -69
- package/src/operations/aggregate.ts +1 -2
- package/src/operations/bulk_write.ts +2 -2
- package/src/operations/command.ts +1 -1
- package/src/operations/execute_operation.ts +131 -137
- package/src/operations/find_and_modify.ts +7 -2
- package/src/operations/insert.ts +4 -3
- package/src/operations/operation.ts +10 -7
- package/src/operations/search_indexes/drop.ts +1 -4
- package/src/sdam/monitor.ts +5 -3
- package/src/sdam/server.ts +1 -1
- package/src/sdam/server_description.ts +6 -5
- package/src/sdam/srv_polling.ts +2 -1
- package/src/sessions.ts +277 -291
- package/src/sort.ts +1 -1
- package/src/timeout.ts +1 -0
- package/src/transactions.ts +2 -1
- package/src/utils.ts +4 -9
- package/src/write_concern.ts +2 -2
- package/tsconfig.json +1 -2
- package/lib/beta.d.ts +0 -7900
- package/lib/beta.js +0 -21
- package/lib/beta.js.map +0 -1
- package/lib/operations/client_bulk_write/command_builder.js +0 -198
- package/lib/operations/client_bulk_write/command_builder.js.map +0 -1
- package/lib/operations/client_bulk_write/common.js +0 -3
- package/lib/operations/client_bulk_write/common.js.map +0 -1
- package/lib/resource_management.js +0 -58
- package/lib/resource_management.js.map +0 -1
- package/src/beta.ts +0 -22
- package/src/operations/client_bulk_write/command_builder.ts +0 -283
- package/src/operations/client_bulk_write/common.ts +0 -146
- package/src/resource_management.ts +0 -74
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Readable, Transform } from 'stream';
|
|
2
2
|
|
|
3
3
|
import { type BSONSerializeOptions, type Document, Long, pluckBSONSerializeOptions } from '../bson';
|
|
4
|
+
import { type OnDemandDocumentDeserializeOptions } from '../cmap/wire_protocol/on_demand/document';
|
|
4
5
|
import { type CursorResponse } from '../cmap/wire_protocol/responses';
|
|
5
6
|
import {
|
|
6
7
|
MongoAPIError,
|
|
@@ -17,7 +18,6 @@ import { GetMoreOperation } from '../operations/get_more';
|
|
|
17
18
|
import { KillCursorsOperation } from '../operations/kill_cursors';
|
|
18
19
|
import { ReadConcern, type ReadConcernLike } from '../read_concern';
|
|
19
20
|
import { ReadPreference, type ReadPreferenceLike } from '../read_preference';
|
|
20
|
-
import { type AsyncDisposable, configureResourceManagement } from '../resource_management';
|
|
21
21
|
import type { Server } from '../sdam/server';
|
|
22
22
|
import { ClientSession, maybeClearPinnedConnection } from '../sessions';
|
|
23
23
|
import { type MongoDBNamespace, squashError } from '../utils';
|
|
@@ -125,12 +125,9 @@ export type AbstractCursorEvents = {
|
|
|
125
125
|
|
|
126
126
|
/** @public */
|
|
127
127
|
export abstract class AbstractCursor<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
extends TypedEventEmitter<CursorEvents>
|
|
132
|
-
implements AsyncDisposable
|
|
133
|
-
{
|
|
128
|
+
TSchema = any,
|
|
129
|
+
CursorEvents extends AbstractCursorEvents = AbstractCursorEvents
|
|
130
|
+
> extends TypedEventEmitter<CursorEvents> {
|
|
134
131
|
/** @internal */
|
|
135
132
|
private cursorId: Long | null;
|
|
136
133
|
/** @internal */
|
|
@@ -157,6 +154,9 @@ export abstract class AbstractCursor<
|
|
|
157
154
|
/** @event */
|
|
158
155
|
static readonly CLOSE = 'close' as const;
|
|
159
156
|
|
|
157
|
+
/** @internal */
|
|
158
|
+
protected deserializationOptions: OnDemandDocumentDeserializeOptions;
|
|
159
|
+
|
|
160
160
|
/** @internal */
|
|
161
161
|
protected constructor(
|
|
162
162
|
client: MongoClient,
|
|
@@ -211,6 +211,13 @@ export abstract class AbstractCursor<
|
|
|
211
211
|
} else {
|
|
212
212
|
this.cursorSession = this.cursorClient.startSession({ owner: this, explicit: false });
|
|
213
213
|
}
|
|
214
|
+
|
|
215
|
+
this.deserializationOptions = {
|
|
216
|
+
...this.cursorOptions,
|
|
217
|
+
validation: {
|
|
218
|
+
utf8: options?.enableUtf8Validation === false ? false : true
|
|
219
|
+
}
|
|
220
|
+
};
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
/**
|
|
@@ -279,32 +286,21 @@ export abstract class AbstractCursor<
|
|
|
279
286
|
return !!this.cursorClient.topology?.loadBalanced;
|
|
280
287
|
}
|
|
281
288
|
|
|
282
|
-
/**
|
|
283
|
-
* @beta
|
|
284
|
-
* @experimental
|
|
285
|
-
* An alias for {@link AbstractCursor.close|AbstractCursor.close()}.
|
|
286
|
-
*/
|
|
287
|
-
declare [Symbol.asyncDispose]: () => Promise<void>;
|
|
288
|
-
/** @internal */
|
|
289
|
-
async asyncDispose() {
|
|
290
|
-
await this.close();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
289
|
/** Returns current buffered documents length */
|
|
294
290
|
bufferedCount(): number {
|
|
295
291
|
return this.documents?.length ?? 0;
|
|
296
292
|
}
|
|
297
293
|
|
|
298
294
|
/** Returns current buffered documents */
|
|
299
|
-
readBufferedDocuments(number?: number):
|
|
300
|
-
const bufferedDocs:
|
|
295
|
+
readBufferedDocuments(number?: number): TSchema[] {
|
|
296
|
+
const bufferedDocs: TSchema[] = [];
|
|
301
297
|
const documentsToRead = Math.min(
|
|
302
298
|
number ?? this.documents?.length ?? 0,
|
|
303
299
|
this.documents?.length ?? 0
|
|
304
300
|
);
|
|
305
301
|
|
|
306
302
|
for (let count = 0; count < documentsToRead; count++) {
|
|
307
|
-
const document = this.documents?.shift(this.
|
|
303
|
+
const document = this.documents?.shift(this.deserializationOptions);
|
|
308
304
|
if (document != null) {
|
|
309
305
|
bufferedDocs.push(document);
|
|
310
306
|
}
|
|
@@ -312,7 +308,6 @@ export abstract class AbstractCursor<
|
|
|
312
308
|
|
|
313
309
|
return bufferedDocs;
|
|
314
310
|
}
|
|
315
|
-
|
|
316
311
|
async *[Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void> {
|
|
317
312
|
if (this.isClosed) {
|
|
318
313
|
return;
|
|
@@ -406,7 +401,7 @@ export abstract class AbstractCursor<
|
|
|
406
401
|
}
|
|
407
402
|
|
|
408
403
|
do {
|
|
409
|
-
const doc = this.documents?.shift(this.
|
|
404
|
+
const doc = this.documents?.shift(this.deserializationOptions);
|
|
410
405
|
if (doc != null) {
|
|
411
406
|
if (this.transform != null) return await this.transformDocument(doc);
|
|
412
407
|
return doc;
|
|
@@ -425,7 +420,7 @@ export abstract class AbstractCursor<
|
|
|
425
420
|
throw new MongoCursorExhaustedError();
|
|
426
421
|
}
|
|
427
422
|
|
|
428
|
-
let doc = this.documents?.shift(this.
|
|
423
|
+
let doc = this.documents?.shift(this.deserializationOptions);
|
|
429
424
|
if (doc != null) {
|
|
430
425
|
if (this.transform != null) return await this.transformDocument(doc);
|
|
431
426
|
return doc;
|
|
@@ -433,7 +428,7 @@ export abstract class AbstractCursor<
|
|
|
433
428
|
|
|
434
429
|
await this.fetchBatch();
|
|
435
430
|
|
|
436
|
-
doc = this.documents?.shift(this.
|
|
431
|
+
doc = this.documents?.shift(this.deserializationOptions);
|
|
437
432
|
if (doc != null) {
|
|
438
433
|
if (this.transform != null) return await this.transformDocument(doc);
|
|
439
434
|
return doc;
|
|
@@ -462,9 +457,6 @@ export abstract class AbstractCursor<
|
|
|
462
457
|
}
|
|
463
458
|
}
|
|
464
459
|
|
|
465
|
-
/**
|
|
466
|
-
* Frees any client-side resources used by the cursor.
|
|
467
|
-
*/
|
|
468
460
|
async close(): Promise<void> {
|
|
469
461
|
await this.cleanup();
|
|
470
462
|
}
|
|
@@ -476,22 +468,13 @@ export abstract class AbstractCursor<
|
|
|
476
468
|
* cursor.rewind() can be used to reset the cursor.
|
|
477
469
|
*/
|
|
478
470
|
async toArray(): Promise<TSchema[]> {
|
|
479
|
-
const array
|
|
480
|
-
// at the end of the loop (since readBufferedDocuments is called) the buffer will be empty
|
|
481
|
-
// then, the 'await of' syntax will run a getMore call
|
|
471
|
+
const array = [];
|
|
482
472
|
for await (const document of this) {
|
|
483
473
|
array.push(document);
|
|
484
|
-
const docs = this.readBufferedDocuments();
|
|
485
|
-
if (this.transform != null) {
|
|
486
|
-
for (const doc of docs) {
|
|
487
|
-
array.push(await this.transformDocument(doc));
|
|
488
|
-
}
|
|
489
|
-
} else {
|
|
490
|
-
array.push(...docs);
|
|
491
|
-
}
|
|
492
474
|
}
|
|
493
475
|
return array;
|
|
494
476
|
}
|
|
477
|
+
|
|
495
478
|
/**
|
|
496
479
|
* Add a cursor flag to the cursor
|
|
497
480
|
*
|
|
@@ -656,6 +639,7 @@ export abstract class AbstractCursor<
|
|
|
656
639
|
// We only want to end this session if we created it, and it hasn't ended yet
|
|
657
640
|
if (session.explicit === false) {
|
|
658
641
|
if (!session.hasEnded) {
|
|
642
|
+
// eslint-disable-next-line github/no-then
|
|
659
643
|
session.endSession().then(undefined, squashError);
|
|
660
644
|
}
|
|
661
645
|
this.cursorSession = this.cursorClient.startSession({ owner: this, explicit: false });
|
|
@@ -831,7 +815,7 @@ export abstract class AbstractCursor<
|
|
|
831
815
|
}
|
|
832
816
|
|
|
833
817
|
/** @internal */
|
|
834
|
-
private async transformDocument(document: NonNullable<TSchema>): Promise<
|
|
818
|
+
private async transformDocument(document: NonNullable<TSchema>): Promise<TSchema> {
|
|
835
819
|
if (this.transform == null) return document;
|
|
836
820
|
|
|
837
821
|
try {
|
|
@@ -881,6 +865,7 @@ class ReadableCursorStream extends Readable {
|
|
|
881
865
|
}
|
|
882
866
|
|
|
883
867
|
override _destroy(error: Error | null, callback: (error?: Error | null) => void): void {
|
|
868
|
+
// eslint-disable-next-line github/no-then
|
|
884
869
|
this._cursor.close().then(
|
|
885
870
|
() => callback(error),
|
|
886
871
|
closeError => callback(closeError)
|
|
@@ -893,11 +878,13 @@ class ReadableCursorStream extends Readable {
|
|
|
893
878
|
return;
|
|
894
879
|
}
|
|
895
880
|
|
|
881
|
+
// eslint-disable-next-line github/no-then
|
|
896
882
|
this._cursor.next().then(
|
|
897
883
|
result => {
|
|
898
884
|
if (result == null) {
|
|
899
885
|
this.push(null);
|
|
900
886
|
} else if (this.destroyed) {
|
|
887
|
+
// eslint-disable-next-line github/no-then
|
|
901
888
|
this._cursor.close().then(undefined, squashError);
|
|
902
889
|
} else {
|
|
903
890
|
if (this.push(result)) {
|
|
@@ -913,6 +900,7 @@ class ReadableCursorStream extends Readable {
|
|
|
913
900
|
// a client during iteration. Alternatively, we could do the "right" thing and
|
|
914
901
|
// propagate the error message by removing this special case.
|
|
915
902
|
if (err.message.match(/server is closed/)) {
|
|
903
|
+
// eslint-disable-next-line github/no-then
|
|
916
904
|
this._cursor.close().then(undefined, squashError);
|
|
917
905
|
return this.push(null);
|
|
918
906
|
}
|
|
@@ -939,5 +927,3 @@ class ReadableCursorStream extends Readable {
|
|
|
939
927
|
);
|
|
940
928
|
}
|
|
941
929
|
}
|
|
942
|
-
|
|
943
|
-
configureResourceManagement(AbstractCursor.prototype);
|
|
@@ -5,12 +5,10 @@ import { AggregateOperation, type AggregateOptions } from '../operations/aggrega
|
|
|
5
5
|
import { executeOperation } from '../operations/execute_operation';
|
|
6
6
|
import type { ClientSession } from '../sessions';
|
|
7
7
|
import type { Sort } from '../sort';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type InitialCursorResponse
|
|
13
|
-
} from './abstract_cursor';
|
|
8
|
+
import type { MongoDBNamespace } from '../utils';
|
|
9
|
+
import { mergeOptions } from '../utils';
|
|
10
|
+
import type { AbstractCursorOptions, InitialCursorResponse } from './abstract_cursor';
|
|
11
|
+
import { AbstractCursor } from './abstract_cursor';
|
|
14
12
|
|
|
15
13
|
/** @public */
|
|
16
14
|
export interface AggregationCursorOptions extends AbstractCursorOptions, AggregateOptions {}
|
|
@@ -76,7 +74,7 @@ export class AggregationCursor<TSchema = any> extends AbstractCursor<TSchema> {
|
|
|
76
74
|
explain: verbosity ?? true
|
|
77
75
|
})
|
|
78
76
|
)
|
|
79
|
-
).shift(this.
|
|
77
|
+
).shift(this.deserializationOptions);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
/** Add a stage to the aggregation pipeline
|
package/src/deps.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
import { type Stream } from './cmap/connect';
|
|
2
3
|
import { MongoMissingDependencyError } from './error';
|
|
3
4
|
import type { Callback } from './utils';
|
|
@@ -23,7 +24,6 @@ export function getKerberos(): Kerberos {
|
|
|
23
24
|
let kerberos: Kerberos;
|
|
24
25
|
try {
|
|
25
26
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
27
27
|
kerberos = require('kerberos');
|
|
28
28
|
} catch (error) {
|
|
29
29
|
kerberos = makeErrorModule(
|
|
@@ -63,7 +63,6 @@ export type ZStandard = ZStandardLib | { kModuleError: MongoMissingDependencyErr
|
|
|
63
63
|
export function getZstdLibrary(): ZStandardLib | { kModuleError: MongoMissingDependencyError } {
|
|
64
64
|
let ZStandard: ZStandardLib | { kModuleError: MongoMissingDependencyError };
|
|
65
65
|
try {
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
67
66
|
ZStandard = require('@mongodb-js/zstd');
|
|
68
67
|
} catch (error) {
|
|
69
68
|
ZStandard = makeErrorModule(
|
|
@@ -102,7 +101,6 @@ export function getAwsCredentialProvider():
|
|
|
102
101
|
| { kModuleError: MongoMissingDependencyError } {
|
|
103
102
|
try {
|
|
104
103
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
106
104
|
const credentialProvider = require('@aws-sdk/credential-providers');
|
|
107
105
|
return credentialProvider;
|
|
108
106
|
} catch (error) {
|
|
@@ -124,7 +122,6 @@ export type GcpMetadata =
|
|
|
124
122
|
export function getGcpMetadata(): GcpMetadata {
|
|
125
123
|
try {
|
|
126
124
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
128
125
|
const credentialProvider = require('gcp-metadata');
|
|
129
126
|
return credentialProvider;
|
|
130
127
|
} catch (error) {
|
|
@@ -156,7 +153,6 @@ export type SnappyLib = {
|
|
|
156
153
|
export function getSnappy(): SnappyLib | { kModuleError: MongoMissingDependencyError } {
|
|
157
154
|
try {
|
|
158
155
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
160
156
|
const value = require('snappy');
|
|
161
157
|
return value;
|
|
162
158
|
} catch (error) {
|
|
@@ -191,7 +187,6 @@ export type SocksLib = {
|
|
|
191
187
|
export function getSocks(): SocksLib | { kModuleError: MongoMissingDependencyError } {
|
|
192
188
|
try {
|
|
193
189
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
195
190
|
const value = require('socks');
|
|
196
191
|
return value;
|
|
197
192
|
} catch (error) {
|
|
@@ -249,7 +244,6 @@ export const aws4: AWS4 | { kModuleError: MongoMissingDependencyError } = loadAw
|
|
|
249
244
|
function loadAws4() {
|
|
250
245
|
let aws4: AWS4 | { kModuleError: MongoMissingDependencyError };
|
|
251
246
|
try {
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
253
247
|
aws4 = require('aws4');
|
|
254
248
|
} catch (error) {
|
|
255
249
|
aws4 = makeErrorModule(
|
|
@@ -273,7 +267,6 @@ export function getMongoDBClientEncryption():
|
|
|
273
267
|
// NOTE(NODE-3199): Ensure you always wrap an optional require literally in the try block
|
|
274
268
|
// Cannot be moved to helper utility function, bundlers search and replace the actual require call
|
|
275
269
|
// in a way that makes this line throw at bundle time, not runtime, catching here will make bundling succeed
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
277
270
|
mongodbClientEncryption = require('mongodb-client-encryption');
|
|
278
271
|
} catch (error) {
|
|
279
272
|
const kModuleError = new MongoMissingDependencyError(
|
package/src/error.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Document } from './bson';
|
|
2
|
-
import type { ServerType } from './sdam/common';
|
|
3
2
|
import type { TopologyVersion } from './sdam/server_description';
|
|
4
3
|
import type { TopologyDescription } from './sdam/topology_description';
|
|
5
4
|
|
|
@@ -1159,23 +1158,6 @@ export class MongoServerSelectionError extends MongoSystemError {
|
|
|
1159
1158
|
}
|
|
1160
1159
|
}
|
|
1161
1160
|
|
|
1162
|
-
/**
|
|
1163
|
-
* The type of the result property of MongoWriteConcernError
|
|
1164
|
-
* @public
|
|
1165
|
-
*/
|
|
1166
|
-
export interface WriteConcernErrorResult {
|
|
1167
|
-
writeConcernError: {
|
|
1168
|
-
code: number;
|
|
1169
|
-
errmsg: string;
|
|
1170
|
-
codeName?: string;
|
|
1171
|
-
errInfo?: Document;
|
|
1172
|
-
};
|
|
1173
|
-
ok: number;
|
|
1174
|
-
code?: number;
|
|
1175
|
-
errorLabels?: string[];
|
|
1176
|
-
[x: string | number]: unknown;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
1161
|
/**
|
|
1180
1162
|
* An error thrown when the server reports a writeConcernError
|
|
1181
1163
|
* @public
|
|
@@ -1196,8 +1178,16 @@ export class MongoWriteConcernError extends MongoServerError {
|
|
|
1196
1178
|
*
|
|
1197
1179
|
* @public
|
|
1198
1180
|
**/
|
|
1199
|
-
constructor(result:
|
|
1200
|
-
|
|
1181
|
+
constructor(result: {
|
|
1182
|
+
writeConcernError: {
|
|
1183
|
+
code: number;
|
|
1184
|
+
errmsg: string;
|
|
1185
|
+
codeName?: string;
|
|
1186
|
+
errInfo?: Document;
|
|
1187
|
+
};
|
|
1188
|
+
errorLabels?: string[];
|
|
1189
|
+
}) {
|
|
1190
|
+
super({ ...result, ...result.writeConcernError });
|
|
1201
1191
|
this.errInfo = result.writeConcernError.errInfo;
|
|
1202
1192
|
this.result = result;
|
|
1203
1193
|
}
|
|
@@ -1227,11 +1217,7 @@ const RETRYABLE_READ_ERROR_CODES = new Set<number>([
|
|
|
1227
1217
|
// see: https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst#terms
|
|
1228
1218
|
const RETRYABLE_WRITE_ERROR_CODES = RETRYABLE_READ_ERROR_CODES;
|
|
1229
1219
|
|
|
1230
|
-
export function needsRetryableWriteLabel(
|
|
1231
|
-
error: Error,
|
|
1232
|
-
maxWireVersion: number,
|
|
1233
|
-
serverType: ServerType
|
|
1234
|
-
): boolean {
|
|
1220
|
+
export function needsRetryableWriteLabel(error: Error, maxWireVersion: number): boolean {
|
|
1235
1221
|
// pre-4.4 server, then the driver adds an error label for every valid case
|
|
1236
1222
|
// execute operation will only inspect the label, code/message logic is handled here
|
|
1237
1223
|
if (error instanceof MongoNetworkError) {
|
|
@@ -1251,16 +1237,11 @@ export function needsRetryableWriteLabel(
|
|
|
1251
1237
|
}
|
|
1252
1238
|
|
|
1253
1239
|
if (error instanceof MongoWriteConcernError) {
|
|
1254
|
-
|
|
1255
|
-
// use original top-level code from server response
|
|
1256
|
-
return RETRYABLE_WRITE_ERROR_CODES.has(error.result.code ?? 0);
|
|
1257
|
-
}
|
|
1258
|
-
const code = error.result.writeConcernError.code ?? Number(error.code);
|
|
1259
|
-
return RETRYABLE_WRITE_ERROR_CODES.has(Number.isNaN(code) ? 0 : code);
|
|
1240
|
+
return RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0);
|
|
1260
1241
|
}
|
|
1261
1242
|
|
|
1262
|
-
if (error instanceof MongoError) {
|
|
1263
|
-
return RETRYABLE_WRITE_ERROR_CODES.has(
|
|
1243
|
+
if (error instanceof MongoError && typeof error.code === 'number') {
|
|
1244
|
+
return RETRYABLE_WRITE_ERROR_CODES.has(error.code);
|
|
1264
1245
|
}
|
|
1265
1246
|
|
|
1266
1247
|
const isNotWritablePrimaryError = LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(error.message);
|
package/src/gridfs/download.ts
CHANGED
|
@@ -56,41 +56,15 @@ export interface GridFSFile {
|
|
|
56
56
|
|
|
57
57
|
/** @internal */
|
|
58
58
|
export interface GridFSBucketReadStreamPrivate {
|
|
59
|
-
/**
|
|
60
|
-
* The running total number of bytes read from the chunks collection.
|
|
61
|
-
*/
|
|
62
59
|
bytesRead: number;
|
|
63
|
-
/**
|
|
64
|
-
* The number of bytes to remove from the last chunk read in the file. This is non-zero
|
|
65
|
-
* if `end` is not equal to the length of the document and `end` is not a multiple
|
|
66
|
-
* of the chunkSize.
|
|
67
|
-
*/
|
|
68
60
|
bytesToTrim: number;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The number of bytes to remove from the first chunk read in the file. This is non-zero
|
|
72
|
-
* if `start` is not equal to the 0 and `start` is not a multiple
|
|
73
|
-
* of the chunkSize.
|
|
74
|
-
*/
|
|
75
61
|
bytesToSkip: number;
|
|
76
|
-
|
|
77
|
-
files: Collection<GridFSFile>;
|
|
78
62
|
chunks: Collection<GridFSChunk>;
|
|
79
63
|
cursor?: FindCursor<GridFSChunk>;
|
|
80
|
-
|
|
81
|
-
/** The running total number of chunks read from the chunks collection. */
|
|
82
64
|
expected: number;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The filter used to search in the _files_ collection (i.e., `{ _id: <> }`)
|
|
86
|
-
* This is not the same filter used when reading chunks from the chunks collection.
|
|
87
|
-
*/
|
|
65
|
+
files: Collection<GridFSFile>;
|
|
88
66
|
filter: Document;
|
|
89
|
-
|
|
90
|
-
/** Indicates whether or not download has started. */
|
|
91
67
|
init: boolean;
|
|
92
|
-
|
|
93
|
-
/** The expected number of chunks to read, calculated from start, end, chunkSize and file length. */
|
|
94
68
|
expectedEnd: number;
|
|
95
69
|
file?: GridFSFile;
|
|
96
70
|
options: {
|
|
@@ -216,7 +190,7 @@ function doRead(stream: GridFSBucketReadStream): void {
|
|
|
216
190
|
|
|
217
191
|
if (!doc) {
|
|
218
192
|
stream.push(null);
|
|
219
|
-
|
|
193
|
+
// eslint-disable-next-line github/no-then
|
|
220
194
|
stream.s.cursor?.close().then(undefined, error => stream.destroy(error));
|
|
221
195
|
return;
|
|
222
196
|
}
|
|
@@ -288,6 +262,7 @@ function doRead(stream: GridFSBucketReadStream): void {
|
|
|
288
262
|
return;
|
|
289
263
|
};
|
|
290
264
|
|
|
265
|
+
// eslint-disable-next-line github/no-then
|
|
291
266
|
stream.s.cursor.next().then(handleReadResult, error => {
|
|
292
267
|
if (stream.destroyed) return;
|
|
293
268
|
stream.destroy(error);
|
|
@@ -371,6 +346,7 @@ function init(stream: GridFSBucketReadStream): void {
|
|
|
371
346
|
return;
|
|
372
347
|
};
|
|
373
348
|
|
|
349
|
+
// eslint-disable-next-line github/no-then
|
|
374
350
|
stream.s.files.findOne(stream.s.filter, findOneOptions).then(handleReadResult, error => {
|
|
375
351
|
if (stream.destroyed) return;
|
|
376
352
|
stream.destroy(error);
|
package/src/gridfs/upload.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Writable } from 'stream';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { Document } from '../bson';
|
|
4
|
+
import { ObjectId } from '../bson';
|
|
4
5
|
import type { Collection } from '../collection';
|
|
5
6
|
import { MongoAPIError, MONGODB_ERROR_CODES, MongoError } from '../error';
|
|
6
7
|
import { type Callback, squashError } from '../utils';
|
|
@@ -134,6 +135,7 @@ export class GridFSBucketWriteStream extends Writable {
|
|
|
134
135
|
if (!this.bucket.s.calledOpenUploadStream) {
|
|
135
136
|
this.bucket.s.calledOpenUploadStream = true;
|
|
136
137
|
|
|
138
|
+
// eslint-disable-next-line github/no-then
|
|
137
139
|
checkIndexes(this).then(() => {
|
|
138
140
|
this.bucket.s.checkedIndexes = true;
|
|
139
141
|
this.bucket.emit('index');
|
|
@@ -270,6 +272,7 @@ function checkDone(stream: GridFSBucketWriteStream, callback: Callback): void {
|
|
|
270
272
|
return;
|
|
271
273
|
}
|
|
272
274
|
|
|
275
|
+
// eslint-disable-next-line github/no-then
|
|
273
276
|
stream.files.insertOne(gridFSFile, { writeConcern: stream.writeConcern }).then(
|
|
274
277
|
() => {
|
|
275
278
|
stream.gridFSFile = gridFSFile;
|
|
@@ -393,6 +396,7 @@ function doWrite(
|
|
|
393
396
|
return;
|
|
394
397
|
}
|
|
395
398
|
|
|
399
|
+
// eslint-disable-next-line github/no-then
|
|
396
400
|
stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
|
|
397
401
|
() => {
|
|
398
402
|
--stream.state.outstandingRequests;
|
|
@@ -433,6 +437,7 @@ function writeRemnant(stream: GridFSBucketWriteStream, callback: Callback): void
|
|
|
433
437
|
return;
|
|
434
438
|
}
|
|
435
439
|
|
|
440
|
+
// eslint-disable-next-line github/no-then
|
|
436
441
|
stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
|
|
437
442
|
() => {
|
|
438
443
|
--stream.state.outstandingRequests;
|
package/src/index.ts
CHANGED
|
@@ -73,10 +73,8 @@ export {
|
|
|
73
73
|
MongoTopologyClosedError,
|
|
74
74
|
MongoTransactionError,
|
|
75
75
|
MongoUnexpectedServerResponseError,
|
|
76
|
-
MongoWriteConcernError
|
|
77
|
-
WriteConcernErrorResult
|
|
76
|
+
MongoWriteConcernError
|
|
78
77
|
} from './error';
|
|
79
|
-
export { configureExplicitResourceManagement } from './resource_management';
|
|
80
78
|
export {
|
|
81
79
|
AbstractCursor,
|
|
82
80
|
// Actual driver classes exported
|
|
@@ -249,7 +247,6 @@ export type {
|
|
|
249
247
|
LocalKMSProviderConfiguration
|
|
250
248
|
} from './client-side-encryption/providers/index';
|
|
251
249
|
export type {
|
|
252
|
-
ClientEncryptionSocketOptions,
|
|
253
250
|
ClientEncryptionTlsOptions,
|
|
254
251
|
CSFLEKMSTlsOptions,
|
|
255
252
|
StateMachineExecutable
|
|
@@ -302,7 +299,11 @@ export type { ClientMetadata, ClientMetadataOptions } from './cmap/handshake/cli
|
|
|
302
299
|
export type { ConnectionPoolMetrics } from './cmap/metrics';
|
|
303
300
|
export type { StreamDescription, StreamDescriptionOptions } from './cmap/stream_description';
|
|
304
301
|
export type { CompressorName } from './cmap/wire_protocol/compression';
|
|
305
|
-
export type {
|
|
302
|
+
export type {
|
|
303
|
+
JSTypeOf,
|
|
304
|
+
OnDemandDocument,
|
|
305
|
+
OnDemandDocumentDeserializeOptions
|
|
306
|
+
} from './cmap/wire_protocol/on_demand/document';
|
|
306
307
|
export type {
|
|
307
308
|
CursorResponse,
|
|
308
309
|
MongoDBResponse,
|
|
@@ -523,7 +524,6 @@ export type {
|
|
|
523
524
|
ReadPreferenceLikeOptions,
|
|
524
525
|
ReadPreferenceOptions
|
|
525
526
|
} from './read_preference';
|
|
526
|
-
export type { AsyncDisposable } from './resource_management';
|
|
527
527
|
export type { ClusterTime, TimerQueue } from './sdam/common';
|
|
528
528
|
export type {
|
|
529
529
|
Monitor,
|
package/src/mongo_client.ts
CHANGED
|
@@ -34,7 +34,6 @@ import { executeOperation } from './operations/execute_operation';
|
|
|
34
34
|
import { RunAdminCommandOperation } from './operations/run_command';
|
|
35
35
|
import type { ReadConcern, ReadConcernLevel, ReadConcernLike } from './read_concern';
|
|
36
36
|
import { ReadPreference, type ReadPreferenceMode } from './read_preference';
|
|
37
|
-
import { type AsyncDisposable, configureResourceManagement } from './resource_management';
|
|
38
37
|
import type { ServerMonitoringMode } from './sdam/monitor';
|
|
39
38
|
import type { TagSet } from './sdam/server_description';
|
|
40
39
|
import { readPreferenceServerSelector } from './sdam/server_selection';
|
|
@@ -105,7 +104,7 @@ export type SupportedTLSSocketOptions = Pick<
|
|
|
105
104
|
|
|
106
105
|
/** @public */
|
|
107
106
|
export type SupportedSocketOptions = Pick<
|
|
108
|
-
TcpNetConnectOpts
|
|
107
|
+
TcpNetConnectOpts,
|
|
109
108
|
(typeof LEGAL_TCP_SOCKET_OPTIONS)[number]
|
|
110
109
|
>;
|
|
111
110
|
|
|
@@ -345,7 +344,7 @@ const kOptions = Symbol('options');
|
|
|
345
344
|
* await client.insertOne({ name: 'spot', kind: 'dog' });
|
|
346
345
|
* ```
|
|
347
346
|
*/
|
|
348
|
-
export class MongoClient extends TypedEventEmitter<MongoClientEvents>
|
|
347
|
+
export class MongoClient extends TypedEventEmitter<MongoClientEvents> {
|
|
349
348
|
/** @internal */
|
|
350
349
|
s: MongoClientPrivate;
|
|
351
350
|
/** @internal */
|
|
@@ -405,17 +404,6 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
|
|
|
405
404
|
this.checkForNonGenuineHosts();
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
/**
|
|
409
|
-
* @beta
|
|
410
|
-
* @experimental
|
|
411
|
-
* An alias for {@link MongoClient.close|MongoClient.close()}.
|
|
412
|
-
*/
|
|
413
|
-
declare [Symbol.asyncDispose]: () => Promise<void>;
|
|
414
|
-
/** @internal */
|
|
415
|
-
async asyncDispose() {
|
|
416
|
-
await this.close();
|
|
417
|
-
}
|
|
418
|
-
|
|
419
407
|
/** @internal */
|
|
420
408
|
private checkForNonGenuineHosts() {
|
|
421
409
|
const documentDBHostnames = this[kOptions].hosts.filter((hostAddress: HostAddress) =>
|
|
@@ -582,15 +570,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
|
|
|
582
570
|
}
|
|
583
571
|
|
|
584
572
|
/**
|
|
585
|
-
*
|
|
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.
|
|
573
|
+
* Close the client and its underlying connections
|
|
594
574
|
*
|
|
595
575
|
* @param force - Force close, emitting no events
|
|
596
576
|
*/
|
|
@@ -778,8 +758,6 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
|
|
|
778
758
|
}
|
|
779
759
|
}
|
|
780
760
|
|
|
781
|
-
configureResourceManagement(MongoClient.prototype);
|
|
782
|
-
|
|
783
761
|
/**
|
|
784
762
|
* Parsed Mongo Client Options.
|
|
785
763
|
*
|
package/src/mongo_logger.ts
CHANGED
|
@@ -604,7 +604,6 @@ export function defaultLogTransform(
|
|
|
604
604
|
log = attachConnectionFields(log, logObject);
|
|
605
605
|
log.message = 'Connection ready';
|
|
606
606
|
log.driverConnectionId = logObject.connectionId;
|
|
607
|
-
log.durationMS = logObject.durationMS;
|
|
608
607
|
return log;
|
|
609
608
|
case CONNECTION_CLOSED:
|
|
610
609
|
log = attachConnectionFields(log, logObject);
|
|
@@ -654,13 +653,11 @@ export function defaultLogTransform(
|
|
|
654
653
|
default:
|
|
655
654
|
log.reason = `Unknown close reason: ${logObject.reason}`;
|
|
656
655
|
}
|
|
657
|
-
log.durationMS = logObject.durationMS;
|
|
658
656
|
return log;
|
|
659
657
|
case CONNECTION_CHECKED_OUT:
|
|
660
658
|
log = attachConnectionFields(log, logObject);
|
|
661
659
|
log.message = 'Connection checked out';
|
|
662
660
|
log.driverConnectionId = logObject.connectionId;
|
|
663
|
-
log.durationMS = logObject.durationMS;
|
|
664
661
|
return log;
|
|
665
662
|
case CONNECTION_CHECKED_IN:
|
|
666
663
|
log = attachConnectionFields(log, logObject);
|
|
@@ -839,9 +836,9 @@ export class MongoLogger {
|
|
|
839
836
|
|
|
840
837
|
if (isPromiseLike(this.pendingLog)) {
|
|
841
838
|
this.pendingLog = this.pendingLog
|
|
842
|
-
|
|
839
|
+
// eslint-disable-next-line github/no-then
|
|
843
840
|
.then(() => this.logDestination.write(logMessage))
|
|
844
|
-
|
|
841
|
+
// eslint-disable-next-line github/no-then
|
|
845
842
|
.then(this.clearPendingLog.bind(this), this.logWriteFailureHandler.bind(this));
|
|
846
843
|
return;
|
|
847
844
|
}
|
|
@@ -849,6 +846,7 @@ export class MongoLogger {
|
|
|
849
846
|
try {
|
|
850
847
|
const logResult = this.logDestination.write(logMessage);
|
|
851
848
|
if (isPromiseLike(logResult)) {
|
|
849
|
+
// eslint-disable-next-line github/no-then
|
|
852
850
|
this.pendingLog = logResult.then(
|
|
853
851
|
this.clearPendingLog.bind(this),
|
|
854
852
|
this.logWriteFailureHandler.bind(this)
|