mongodb 6.8.0-dev.20240822.sha.f5254030 → 6.8.0-dev.20240829.sha.6d65ae77
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 +29 -5
- package/lib/beta.js +0 -1
- package/lib/beta.js.map +1 -1
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +9 -11
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +0 -6
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +1 -1
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connection.js +0 -2
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +0 -1
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +1 -1
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +0 -2
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +0 -5
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/deps.js +8 -0
- package/lib/deps.js.map +1 -1
- package/lib/error.js +2 -1
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +0 -3
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/upload.js +0 -4
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/mongo_logger.js +0 -3
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +1 -0
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +1 -0
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/client_bulk_write/command_builder.js +198 -0
- package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/lib/operations/client_bulk_write/common.js +3 -0
- package/lib/operations/client_bulk_write/common.js.map +1 -0
- package/lib/operations/execute_operation.js +2 -1
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find_and_modify.js +1 -1
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/operation.js +1 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/resource_management.js +4 -4
- package/lib/resource_management.js.map +1 -1
- package/lib/sdam/monitor.js +1 -5
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/srv_polling.js +1 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sessions.js +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +1 -1
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +0 -1
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +29 -5
- package/package.json +23 -25
- package/src/beta.ts +1 -1
- package/src/bson.ts +1 -2
- package/src/bulk/common.ts +12 -9
- package/src/change_stream.ts +10 -11
- package/src/client-side-encryption/mongocryptd_manager.ts +1 -1
- 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 -1
- package/src/cmap/connection.ts +2 -2
- package/src/cmap/connection_pool.ts +0 -1
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/shared.ts +1 -2
- package/src/collection.ts +13 -12
- package/src/connection_string.ts +1 -2
- package/src/constants.ts +1 -0
- package/src/cursor/abstract_cursor.ts +0 -5
- package/src/cursor/aggregation_cursor.ts +6 -4
- package/src/deps.ts +8 -1
- package/src/error.ts +2 -3
- package/src/gridfs/download.ts +1 -3
- package/src/gridfs/upload.ts +1 -6
- package/src/mongo_logger.ts +2 -3
- package/src/mongo_types.ts +69 -68
- package/src/operations/aggregate.ts +2 -1
- package/src/operations/client_bulk_write/command_builder.ts +283 -0
- package/src/operations/client_bulk_write/common.ts +146 -0
- package/src/operations/execute_operation.ts +6 -4
- package/src/operations/find_and_modify.ts +1 -1
- package/src/operations/insert.ts +1 -2
- package/src/operations/operation.ts +5 -8
- package/src/operations/search_indexes/drop.ts +4 -1
- package/src/resource_management.ts +4 -4
- package/src/sdam/monitor.ts +3 -5
- package/src/sdam/server_description.ts +5 -6
- package/src/sdam/srv_polling.ts +1 -2
- package/src/sessions.ts +1 -1
- package/src/sort.ts +1 -1
- package/src/timeout.ts +0 -1
- package/src/transactions.ts +1 -2
- package/src/utils.ts +9 -4
- package/src/write_concern.ts +2 -2
package/src/change_stream.ts
CHANGED
|
@@ -44,7 +44,7 @@ const CHANGE_DOMAIN_TYPES = {
|
|
|
44
44
|
CLUSTER: Symbol('Cluster')
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE];
|
|
47
|
+
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE] as const;
|
|
48
48
|
|
|
49
49
|
const NO_RESUME_TOKEN_ERROR =
|
|
50
50
|
'A change stream document has been received that lacks a resume token (_id).';
|
|
@@ -680,7 +680,7 @@ export class ChangeStream<
|
|
|
680
680
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
681
681
|
// This loop continues until either a change event is received or until a resume attempt
|
|
682
682
|
// fails.
|
|
683
|
-
|
|
683
|
+
|
|
684
684
|
while (true) {
|
|
685
685
|
try {
|
|
686
686
|
const hasNext = await this.cursor.hasNext();
|
|
@@ -706,7 +706,7 @@ export class ChangeStream<
|
|
|
706
706
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
707
707
|
// This loop continues until either a change event is received or until a resume attempt
|
|
708
708
|
// fails.
|
|
709
|
-
|
|
709
|
+
|
|
710
710
|
while (true) {
|
|
711
711
|
try {
|
|
712
712
|
const change = await this.cursor.next();
|
|
@@ -735,7 +735,7 @@ export class ChangeStream<
|
|
|
735
735
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
736
736
|
// This loop continues until either a change event is received or until a resume attempt
|
|
737
737
|
// fails.
|
|
738
|
-
|
|
738
|
+
|
|
739
739
|
while (true) {
|
|
740
740
|
try {
|
|
741
741
|
const change = await this.cursor.tryNext();
|
|
@@ -850,10 +850,10 @@ export class ChangeStream<
|
|
|
850
850
|
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
|
|
851
851
|
? (this.parent as MongoClient)
|
|
852
852
|
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
853
|
+
? (this.parent as Db).client
|
|
854
|
+
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
|
|
855
|
+
? (this.parent as Collection).client
|
|
856
|
+
: null;
|
|
857
857
|
|
|
858
858
|
if (client == null) {
|
|
859
859
|
// This should never happen because of the assertion in the constructor
|
|
@@ -884,7 +884,6 @@ export class ChangeStream<
|
|
|
884
884
|
private _closeEmitterModeWithError(error: AnyError): void {
|
|
885
885
|
this.emit(ChangeStream.ERROR, error);
|
|
886
886
|
|
|
887
|
-
// eslint-disable-next-line github/no-then
|
|
888
887
|
this.close().then(undefined, squashError);
|
|
889
888
|
}
|
|
890
889
|
|
|
@@ -949,7 +948,7 @@ export class ChangeStream<
|
|
|
949
948
|
|
|
950
949
|
if (isResumableError(changeStreamError, this.cursor.maxWireVersion)) {
|
|
951
950
|
this._endStream();
|
|
952
|
-
|
|
951
|
+
|
|
953
952
|
this.cursor.close().then(undefined, squashError);
|
|
954
953
|
|
|
955
954
|
const topology = getTopology(this.parent);
|
|
@@ -957,7 +956,7 @@ export class ChangeStream<
|
|
|
957
956
|
.selectServer(this.cursor.readPreference, {
|
|
958
957
|
operationName: 'reconnect topology in change stream'
|
|
959
958
|
})
|
|
960
|
-
|
|
959
|
+
|
|
961
960
|
.then(
|
|
962
961
|
() => {
|
|
963
962
|
this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
|
|
@@ -49,7 +49,7 @@ export class MongocryptdManager {
|
|
|
49
49
|
async spawn(): Promise<void> {
|
|
50
50
|
const cmdName = this.spawnPath || 'mongocryptd';
|
|
51
51
|
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
53
53
|
const { spawn } = require('child_process') as typeof import('child_process');
|
|
54
54
|
|
|
55
55
|
// Spawned with stdio: ignore and detached: true
|
package/src/cmap/auth/gssapi.ts
CHANGED
|
@@ -168,7 +168,7 @@ export async function performGSSAPICanonicalizeHostName(
|
|
|
168
168
|
const results = await dns.promises.resolvePtr(address);
|
|
169
169
|
// If the ptr did not error but had no results, return the host.
|
|
170
170
|
return results.length > 0 ? results[0] : host;
|
|
171
|
-
} catch
|
|
171
|
+
} catch {
|
|
172
172
|
// This can error as ptr records may not exist for all ips. In this case
|
|
173
173
|
// fallback to a cname lookup as dns.lookup() does not return the
|
|
174
174
|
// cname.
|
|
@@ -78,8 +78,8 @@ export class MongoDBAWS extends AuthProvider {
|
|
|
78
78
|
accessKeyId && secretAccessKey && sessionToken
|
|
79
79
|
? { accessKeyId, secretAccessKey, sessionToken }
|
|
80
80
|
: accessKeyId && secretAccessKey
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
? { accessKeyId, secretAccessKey }
|
|
82
|
+
: undefined;
|
|
83
83
|
|
|
84
84
|
const db = credentials.source;
|
|
85
85
|
const nonce = await randomBytes(32);
|
|
@@ -160,9 +160,9 @@ export abstract class CallbackWorkflow implements Workflow {
|
|
|
160
160
|
// previous lock, only the current callback's value would get returned.
|
|
161
161
|
await lock;
|
|
162
162
|
lock = lock
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
.catch(() => null)
|
|
165
|
-
|
|
165
|
+
|
|
166
166
|
.then(async () => {
|
|
167
167
|
const difference = Date.now() - this.lastExecutionTime;
|
|
168
168
|
if (difference <= THROTTLE_MS) {
|
|
@@ -115,9 +115,9 @@ export abstract class MachineWorkflow implements Workflow {
|
|
|
115
115
|
// previous lock, only the current callback's value would get returned.
|
|
116
116
|
await lock;
|
|
117
117
|
lock = lock
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
.catch(() => null)
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
.then(async () => {
|
|
122
122
|
const difference = Date.now() - this.lastExecutionTime;
|
|
123
123
|
if (difference <= THROTTLE_MS) {
|
package/src/cmap/commands.ts
CHANGED
|
@@ -75,7 +75,11 @@ export class OpQueryRequest {
|
|
|
75
75
|
exhaust: boolean;
|
|
76
76
|
partial: boolean;
|
|
77
77
|
|
|
78
|
-
constructor(
|
|
78
|
+
constructor(
|
|
79
|
+
public databaseName: string,
|
|
80
|
+
public query: Document,
|
|
81
|
+
options: OpQueryOptions
|
|
82
|
+
) {
|
|
79
83
|
// Basic options needed to be passed in
|
|
80
84
|
// TODO(NODE-3483): Replace with MongoCommandError
|
|
81
85
|
const ns = `${databaseName}.$cmd`;
|
package/src/cmap/connection.ts
CHANGED
|
@@ -332,7 +332,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
|
|
|
332
332
|
|
|
333
333
|
this.socket.destroy();
|
|
334
334
|
this.error = error;
|
|
335
|
-
|
|
335
|
+
|
|
336
336
|
this.dataEvents?.throw(error).then(undefined, squashError);
|
|
337
337
|
this.closed = true;
|
|
338
338
|
this.emit(Connection.CLOSE);
|
|
@@ -602,7 +602,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
|
|
|
602
602
|
}
|
|
603
603
|
throw new MongoUnexpectedServerResponseError('Server ended moreToCome unexpectedly');
|
|
604
604
|
};
|
|
605
|
-
|
|
605
|
+
|
|
606
606
|
exhaustLoop().then(undefined, replyListener);
|
|
607
607
|
}
|
|
608
608
|
|
|
@@ -638,7 +638,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
|
|
|
638
638
|
new ConnectionCreatedEvent(this, { id: connectOptions.id })
|
|
639
639
|
);
|
|
640
640
|
|
|
641
|
-
// eslint-disable-next-line github/no-then
|
|
642
641
|
connect(connectOptions).then(
|
|
643
642
|
connection => {
|
|
644
643
|
// The pool might have closed since we started trying to create a connection
|
|
@@ -6,7 +6,7 @@ import { MongoInvalidArgumentError } from '../../error';
|
|
|
6
6
|
import type { MongoOptions } from '../../mongo_client';
|
|
7
7
|
import { fileIsAccessible } from '../../utils';
|
|
8
8
|
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
10
|
const NODE_DRIVER_VERSION = require('../../../package.json').version;
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MongoInvalidArgumentError } from '../../error';
|
|
2
|
-
import type
|
|
3
|
-
import { ReadPreference } from '../../read_preference';
|
|
2
|
+
import { ReadPreference, type ReadPreferenceLike } from '../../read_preference';
|
|
4
3
|
import { ServerType } from '../../sdam/common';
|
|
5
4
|
import type { Server } from '../../sdam/server';
|
|
6
5
|
import type { ServerDescription } from '../../sdam/server_description';
|
package/src/collection.ts
CHANGED
|
@@ -47,17 +47,18 @@ import {
|
|
|
47
47
|
FindOneAndUpdateOperation,
|
|
48
48
|
type FindOneAndUpdateOptions
|
|
49
49
|
} from './operations/find_and_modify';
|
|
50
|
-
import
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
import {
|
|
51
|
+
CreateIndexesOperation,
|
|
52
|
+
type CreateIndexesOptions,
|
|
53
|
+
type DropIndexesOptions,
|
|
54
|
+
DropIndexOperation,
|
|
55
|
+
type IndexDescription,
|
|
56
|
+
type IndexDescriptionCompact,
|
|
57
|
+
type IndexDescriptionInfo,
|
|
58
|
+
type IndexInformationOptions,
|
|
59
|
+
type IndexSpecification,
|
|
60
|
+
type ListIndexesOptions
|
|
59
61
|
} from './operations/indexes';
|
|
60
|
-
import { CreateIndexesOperation, DropIndexOperation } from './operations/indexes';
|
|
61
62
|
import {
|
|
62
63
|
InsertManyOperation,
|
|
63
64
|
type InsertManyResult,
|
|
@@ -1121,8 +1122,8 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
1121
1122
|
indexNameOrOptions == null
|
|
1122
1123
|
? null
|
|
1123
1124
|
: typeof indexNameOrOptions === 'object'
|
|
1124
|
-
|
|
1125
|
-
|
|
1125
|
+
? null
|
|
1126
|
+
: indexNameOrOptions;
|
|
1126
1127
|
|
|
1127
1128
|
return new ListSearchIndexesCursor(this as TODO_NODE_3286, indexName, options);
|
|
1128
1129
|
}
|
package/src/connection_string.ts
CHANGED
|
@@ -73,7 +73,7 @@ export async function resolveSRVRecord(options: MongoOptions): Promise<HostAddre
|
|
|
73
73
|
// the SRV record is resolved before starting a second DNS query.
|
|
74
74
|
const lookupAddress = options.srvHost;
|
|
75
75
|
const txtResolutionPromise = dns.promises.resolveTxt(lookupAddress);
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
txtResolutionPromise.then(undefined, squashError); // rejections will be handled later
|
|
78
78
|
|
|
79
79
|
// Resolve the SRV record and use the result as the list of hosts to connect to.
|
|
@@ -552,7 +552,6 @@ export function parseOptions(
|
|
|
552
552
|
|
|
553
553
|
mongoOptions.metadata = makeClientMetadata(mongoOptions);
|
|
554
554
|
|
|
555
|
-
// eslint-disable-next-line github/no-then
|
|
556
555
|
mongoOptions.extendedMetadata = addContainerMetadata(mongoOptions.metadata).then(
|
|
557
556
|
undefined,
|
|
558
557
|
squashError
|
package/src/constants.ts
CHANGED
|
@@ -656,7 +656,6 @@ export abstract class AbstractCursor<
|
|
|
656
656
|
// We only want to end this session if we created it, and it hasn't ended yet
|
|
657
657
|
if (session.explicit === false) {
|
|
658
658
|
if (!session.hasEnded) {
|
|
659
|
-
// eslint-disable-next-line github/no-then
|
|
660
659
|
session.endSession().then(undefined, squashError);
|
|
661
660
|
}
|
|
662
661
|
this.cursorSession = this.cursorClient.startSession({ owner: this, explicit: false });
|
|
@@ -882,7 +881,6 @@ class ReadableCursorStream extends Readable {
|
|
|
882
881
|
}
|
|
883
882
|
|
|
884
883
|
override _destroy(error: Error | null, callback: (error?: Error | null) => void): void {
|
|
885
|
-
// eslint-disable-next-line github/no-then
|
|
886
884
|
this._cursor.close().then(
|
|
887
885
|
() => callback(error),
|
|
888
886
|
closeError => callback(closeError)
|
|
@@ -895,13 +893,11 @@ class ReadableCursorStream extends Readable {
|
|
|
895
893
|
return;
|
|
896
894
|
}
|
|
897
895
|
|
|
898
|
-
// eslint-disable-next-line github/no-then
|
|
899
896
|
this._cursor.next().then(
|
|
900
897
|
result => {
|
|
901
898
|
if (result == null) {
|
|
902
899
|
this.push(null);
|
|
903
900
|
} else if (this.destroyed) {
|
|
904
|
-
// eslint-disable-next-line github/no-then
|
|
905
901
|
this._cursor.close().then(undefined, squashError);
|
|
906
902
|
} else {
|
|
907
903
|
if (this.push(result)) {
|
|
@@ -917,7 +913,6 @@ class ReadableCursorStream extends Readable {
|
|
|
917
913
|
// a client during iteration. Alternatively, we could do the "right" thing and
|
|
918
914
|
// propagate the error message by removing this special case.
|
|
919
915
|
if (err.message.match(/server is closed/)) {
|
|
920
|
-
// eslint-disable-next-line github/no-then
|
|
921
916
|
this._cursor.close().then(undefined, squashError);
|
|
922
917
|
return this.push(null);
|
|
923
918
|
}
|
|
@@ -5,10 +5,12 @@ 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 type
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { mergeOptions, type MongoDBNamespace } from '../utils';
|
|
9
|
+
import {
|
|
10
|
+
AbstractCursor,
|
|
11
|
+
type AbstractCursorOptions,
|
|
12
|
+
type InitialCursorResponse
|
|
13
|
+
} from './abstract_cursor';
|
|
12
14
|
|
|
13
15
|
/** @public */
|
|
14
16
|
export interface AggregationCursorOptions extends AbstractCursorOptions, AggregateOptions {}
|
package/src/deps.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
1
|
import { type Stream } from './cmap/connect';
|
|
3
2
|
import { MongoMissingDependencyError } from './error';
|
|
4
3
|
import type { Callback } from './utils';
|
|
@@ -24,6 +23,7 @@ export function getKerberos(): Kerberos {
|
|
|
24
23
|
let kerberos: Kerberos;
|
|
25
24
|
try {
|
|
26
25
|
// 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,6 +63,7 @@ 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
|
|
66
67
|
ZStandard = require('@mongodb-js/zstd');
|
|
67
68
|
} catch (error) {
|
|
68
69
|
ZStandard = makeErrorModule(
|
|
@@ -101,6 +102,7 @@ export function getAwsCredentialProvider():
|
|
|
101
102
|
| { kModuleError: MongoMissingDependencyError } {
|
|
102
103
|
try {
|
|
103
104
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
104
106
|
const credentialProvider = require('@aws-sdk/credential-providers');
|
|
105
107
|
return credentialProvider;
|
|
106
108
|
} catch (error) {
|
|
@@ -122,6 +124,7 @@ export type GcpMetadata =
|
|
|
122
124
|
export function getGcpMetadata(): GcpMetadata {
|
|
123
125
|
try {
|
|
124
126
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
125
128
|
const credentialProvider = require('gcp-metadata');
|
|
126
129
|
return credentialProvider;
|
|
127
130
|
} catch (error) {
|
|
@@ -153,6 +156,7 @@ export type SnappyLib = {
|
|
|
153
156
|
export function getSnappy(): SnappyLib | { kModuleError: MongoMissingDependencyError } {
|
|
154
157
|
try {
|
|
155
158
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
156
160
|
const value = require('snappy');
|
|
157
161
|
return value;
|
|
158
162
|
} catch (error) {
|
|
@@ -187,6 +191,7 @@ export type SocksLib = {
|
|
|
187
191
|
export function getSocks(): SocksLib | { kModuleError: MongoMissingDependencyError } {
|
|
188
192
|
try {
|
|
189
193
|
// Ensure you always wrap an optional require in the try block NODE-3199
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
190
195
|
const value = require('socks');
|
|
191
196
|
return value;
|
|
192
197
|
} catch (error) {
|
|
@@ -244,6 +249,7 @@ export const aws4: AWS4 | { kModuleError: MongoMissingDependencyError } = loadAw
|
|
|
244
249
|
function loadAws4() {
|
|
245
250
|
let aws4: AWS4 | { kModuleError: MongoMissingDependencyError };
|
|
246
251
|
try {
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
247
253
|
aws4 = require('aws4');
|
|
248
254
|
} catch (error) {
|
|
249
255
|
aws4 = makeErrorModule(
|
|
@@ -267,6 +273,7 @@ export function getMongoDBClientEncryption():
|
|
|
267
273
|
// NOTE(NODE-3199): Ensure you always wrap an optional require literally in the try block
|
|
268
274
|
// Cannot be moved to helper utility function, bundlers search and replace the actual require call
|
|
269
275
|
// 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
|
|
270
277
|
mongodbClientEncryption = require('mongodb-client-encryption');
|
|
271
278
|
} catch (error) {
|
|
272
279
|
const kModuleError = new MongoMissingDependencyError(
|
package/src/error.ts
CHANGED
|
@@ -1255,9 +1255,8 @@ export function needsRetryableWriteLabel(
|
|
|
1255
1255
|
// use original top-level code from server response
|
|
1256
1256
|
return RETRYABLE_WRITE_ERROR_CODES.has(error.result.code ?? 0);
|
|
1257
1257
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
);
|
|
1258
|
+
const code = error.result.writeConcernError.code ?? Number(error.code);
|
|
1259
|
+
return RETRYABLE_WRITE_ERROR_CODES.has(Number.isNaN(code) ? 0 : code);
|
|
1261
1260
|
}
|
|
1262
1261
|
|
|
1263
1262
|
if (error instanceof MongoError) {
|
package/src/gridfs/download.ts
CHANGED
|
@@ -216,7 +216,7 @@ function doRead(stream: GridFSBucketReadStream): void {
|
|
|
216
216
|
|
|
217
217
|
if (!doc) {
|
|
218
218
|
stream.push(null);
|
|
219
|
-
|
|
219
|
+
|
|
220
220
|
stream.s.cursor?.close().then(undefined, error => stream.destroy(error));
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
@@ -288,7 +288,6 @@ function doRead(stream: GridFSBucketReadStream): void {
|
|
|
288
288
|
return;
|
|
289
289
|
};
|
|
290
290
|
|
|
291
|
-
// eslint-disable-next-line github/no-then
|
|
292
291
|
stream.s.cursor.next().then(handleReadResult, error => {
|
|
293
292
|
if (stream.destroyed) return;
|
|
294
293
|
stream.destroy(error);
|
|
@@ -372,7 +371,6 @@ function init(stream: GridFSBucketReadStream): void {
|
|
|
372
371
|
return;
|
|
373
372
|
};
|
|
374
373
|
|
|
375
|
-
// eslint-disable-next-line github/no-then
|
|
376
374
|
stream.s.files.findOne(stream.s.filter, findOneOptions).then(handleReadResult, error => {
|
|
377
375
|
if (stream.destroyed) return;
|
|
378
376
|
stream.destroy(error);
|
package/src/gridfs/upload.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Writable } from 'stream';
|
|
2
2
|
|
|
3
|
-
import type
|
|
4
|
-
import { ObjectId } from '../bson';
|
|
3
|
+
import { type Document, ObjectId } from '../bson';
|
|
5
4
|
import type { Collection } from '../collection';
|
|
6
5
|
import { MongoAPIError, MONGODB_ERROR_CODES, MongoError } from '../error';
|
|
7
6
|
import { type Callback, squashError } from '../utils';
|
|
@@ -135,7 +134,6 @@ export class GridFSBucketWriteStream extends Writable {
|
|
|
135
134
|
if (!this.bucket.s.calledOpenUploadStream) {
|
|
136
135
|
this.bucket.s.calledOpenUploadStream = true;
|
|
137
136
|
|
|
138
|
-
// eslint-disable-next-line github/no-then
|
|
139
137
|
checkIndexes(this).then(() => {
|
|
140
138
|
this.bucket.s.checkedIndexes = true;
|
|
141
139
|
this.bucket.emit('index');
|
|
@@ -272,7 +270,6 @@ function checkDone(stream: GridFSBucketWriteStream, callback: Callback): void {
|
|
|
272
270
|
return;
|
|
273
271
|
}
|
|
274
272
|
|
|
275
|
-
// eslint-disable-next-line github/no-then
|
|
276
273
|
stream.files.insertOne(gridFSFile, { writeConcern: stream.writeConcern }).then(
|
|
277
274
|
() => {
|
|
278
275
|
stream.gridFSFile = gridFSFile;
|
|
@@ -396,7 +393,6 @@ function doWrite(
|
|
|
396
393
|
return;
|
|
397
394
|
}
|
|
398
395
|
|
|
399
|
-
// eslint-disable-next-line github/no-then
|
|
400
396
|
stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
|
|
401
397
|
() => {
|
|
402
398
|
--stream.state.outstandingRequests;
|
|
@@ -437,7 +433,6 @@ function writeRemnant(stream: GridFSBucketWriteStream, callback: Callback): void
|
|
|
437
433
|
return;
|
|
438
434
|
}
|
|
439
435
|
|
|
440
|
-
// eslint-disable-next-line github/no-then
|
|
441
436
|
stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
|
|
442
437
|
() => {
|
|
443
438
|
--stream.state.outstandingRequests;
|
package/src/mongo_logger.ts
CHANGED
|
@@ -839,9 +839,9 @@ export class MongoLogger {
|
|
|
839
839
|
|
|
840
840
|
if (isPromiseLike(this.pendingLog)) {
|
|
841
841
|
this.pendingLog = this.pendingLog
|
|
842
|
-
|
|
842
|
+
|
|
843
843
|
.then(() => this.logDestination.write(logMessage))
|
|
844
|
-
|
|
844
|
+
|
|
845
845
|
.then(this.clearPendingLog.bind(this), this.logWriteFailureHandler.bind(this));
|
|
846
846
|
return;
|
|
847
847
|
}
|
|
@@ -849,7 +849,6 @@ export class MongoLogger {
|
|
|
849
849
|
try {
|
|
850
850
|
const logResult = this.logDestination.write(logMessage);
|
|
851
851
|
if (isPromiseLike(logResult)) {
|
|
852
|
-
// eslint-disable-next-line github/no-then
|
|
853
852
|
this.pendingLog = logResult.then(
|
|
854
853
|
this.clearPendingLog.bind(this),
|
|
855
854
|
this.logWriteFailureHandler.bind(this)
|