mongodb 6.13.0 → 6.13.1-dev.20250222.sha.421ddeb3
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 +16 -7
- package/lib/change_stream.js +4 -5
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +0 -1
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/connect.js +0 -1
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +1 -0
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +1 -0
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +1 -0
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/error.js +2 -2
- package/lib/error.js.map +1 -1
- package/lib/gridfs/index.js +1 -0
- package/lib/gridfs/index.js.map +1 -1
- package/lib/mongo_client.js +1 -0
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_types.js +5 -0
- package/lib/mongo_types.js.map +1 -1
- package/lib/sdam/monitor.js +1 -0
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +1 -0
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/srv_polling.js +1 -0
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +1 -0
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +10 -3
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +1 -0
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +5 -3
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +16 -7
- package/package.json +34 -35
- package/src/change_stream.ts +4 -6
- package/src/client-side-encryption/state_machine.ts +0 -1
- package/src/cmap/auth/mongodb_aws.ts +1 -1
- package/src/cmap/connect.ts +0 -1
- package/src/cmap/connection.ts +2 -0
- package/src/cmap/connection_pool.ts +2 -0
- package/src/collection.ts +15 -7
- package/src/cursor/abstract_cursor.ts +2 -0
- package/src/error.ts +4 -12
- package/src/gridfs/index.ts +2 -1
- package/src/mongo_client.ts +2 -0
- package/src/mongo_types.ts +7 -1
- package/src/sdam/monitor.ts +2 -0
- package/src/sdam/server.ts +2 -0
- package/src/sdam/srv_polling.ts +2 -1
- package/src/sdam/topology.ts +2 -0
- package/src/sdam/topology_description.ts +22 -3
- package/src/sessions.ts +2 -0
- package/src/utils.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb",
|
|
3
|
-
"version": "6.13.
|
|
3
|
+
"version": "6.13.1-dev.20250222.sha.421ddeb3",
|
|
4
4
|
"description": "The official MongoDB driver for Node.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@mongodb-js/saslprep": "^1.1.9",
|
|
29
|
-
"bson": "^6.10.
|
|
29
|
+
"bson": "^6.10.3",
|
|
30
30
|
"mongodb-connection-string-url": "^3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@aws-sdk/credential-providers": "^3.
|
|
33
|
+
"@aws-sdk/credential-providers": "^3.632.0",
|
|
34
34
|
"@mongodb-js/zstd": "^1.1.0 || ^2.0.0",
|
|
35
35
|
"gcp-metadata": "^5.2.0",
|
|
36
36
|
"kerberos": "^2.0.1",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@aws-sdk/credential-providers": "^3.
|
|
65
|
+
"@aws-sdk/credential-providers": "^3.632.0",
|
|
66
66
|
"@iarna/toml": "^2.2.5",
|
|
67
67
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
68
|
-
"@microsoft/api-extractor": "^7.
|
|
69
|
-
"@microsoft/tsdoc-config": "^0.17.
|
|
68
|
+
"@microsoft/api-extractor": "^7.49.2",
|
|
69
|
+
"@microsoft/tsdoc-config": "^0.17.1",
|
|
70
70
|
"@mongodb-js/zstd": "^2.0.0",
|
|
71
71
|
"@types/chai": "^4.3.17",
|
|
72
72
|
"@types/chai-subset": "^1.3.5",
|
|
73
73
|
"@types/express": "^4.17.21",
|
|
74
74
|
"@types/kerberos": "^1.1.5",
|
|
75
75
|
"@types/mocha": "^10.0.9",
|
|
76
|
-
"@types/node": "^22.
|
|
76
|
+
"@types/node": "^22.13.0",
|
|
77
77
|
"@types/saslprep": "^1.0.3",
|
|
78
78
|
"@types/semver": "^7.5.8",
|
|
79
79
|
"@types/sinon": "^17.0.3",
|
|
@@ -87,20 +87,20 @@
|
|
|
87
87
|
"eslint": "9.9.0",
|
|
88
88
|
"eslint-config-prettier": "^9.1.0",
|
|
89
89
|
"eslint-plugin-mocha": "^10.4.1",
|
|
90
|
-
"eslint-plugin-prettier": "^5.2.
|
|
90
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
91
91
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
92
|
-
"eslint-plugin-tsdoc": "^0.
|
|
92
|
+
"eslint-plugin-tsdoc": "^0.4.0",
|
|
93
93
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
94
|
-
"express": "^4.21.
|
|
94
|
+
"express": "^4.21.2",
|
|
95
95
|
"gcp-metadata": "^5.3.0",
|
|
96
96
|
"js-yaml": "^4.1.0",
|
|
97
97
|
"mocha": "^10.8.2",
|
|
98
98
|
"mocha-sinon": "^2.1.2",
|
|
99
|
-
"mongodb-client-encryption": "^6.
|
|
99
|
+
"mongodb-client-encryption": "^6.2.0",
|
|
100
100
|
"mongodb-legacy": "^6.1.3",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
|
-
"prettier": "^3.
|
|
103
|
-
"semver": "^7.
|
|
102
|
+
"prettier": "^3.4.2",
|
|
103
|
+
"semver": "^7.7.0",
|
|
104
104
|
"sinon": "^18.0.0",
|
|
105
105
|
"sinon-chai": "^3.7.0",
|
|
106
106
|
"snappy": "^7.2.2",
|
|
@@ -128,36 +128,35 @@
|
|
|
128
128
|
"build:docs": "./etc/docs/build.ts",
|
|
129
129
|
"build:typedoc": "typedoc",
|
|
130
130
|
"build:nightly": "node ./.github/scripts/nightly.mjs",
|
|
131
|
-
"check:bench": "
|
|
131
|
+
"check:bench": "npm --prefix test/benchmarks/driver_bench start",
|
|
132
132
|
"check:coverage": "nyc npm run test:all",
|
|
133
133
|
"check:integration-coverage": "nyc npm run check:test",
|
|
134
|
-
"check:lambda": "mocha --config test/mocha_lambda.
|
|
135
|
-
"check:lambda:aws": "mocha --config test/mocha_lambda.
|
|
134
|
+
"check:lambda": "mocha --config test/mocha_lambda.js test/integration/node-specific/examples/handler.test.js",
|
|
135
|
+
"check:lambda:aws": "mocha --config test/mocha_lambda.js test/integration/node-specific/examples/aws_handler.test.js",
|
|
136
136
|
"check:lint": "npm run build:dts && npm run check:dts && npm run check:eslint && npm run check:tsd",
|
|
137
137
|
"check:eslint": "npm run build:dts && ESLINT_USE_FLAT_CONFIG=false eslint -v && ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ext '.js,.ts' src test",
|
|
138
138
|
"check:tsd": "tsd --version && tsd",
|
|
139
139
|
"check:dependencies": "mocha test/action/dependency.test.ts",
|
|
140
140
|
"check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
|
|
141
|
-
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.
|
|
142
|
-
"check:test": "mocha --config test/mocha_mongodb.
|
|
141
|
+
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts",
|
|
142
|
+
"check:test": "mocha --config test/mocha_mongodb.js test/integration",
|
|
143
143
|
"check:unit": "mocha test/unit",
|
|
144
144
|
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
|
|
145
|
-
"check:atlas": "mocha --config test/manual/mocharc.
|
|
146
|
-
"check:resource-management": "mocha --config test/manual/mocharc.
|
|
147
|
-
"check:drivers-atlas-testing": "mocha --config test/mocha_mongodb.
|
|
148
|
-
"check:adl": "mocha --config test/mocha_mongodb.
|
|
149
|
-
"check:aws": "nyc mocha --config test/mocha_mongodb.
|
|
150
|
-
"check:oidc-auth": "mocha --config test/mocha_mongodb.
|
|
151
|
-
"check:oidc-test": "mocha --config test/mocha_mongodb.
|
|
152
|
-
"check:oidc-azure": "mocha --config test/mocha_mongodb.
|
|
153
|
-
"check:oidc-gcp": "mocha --config test/mocha_mongodb.
|
|
154
|
-
"check:oidc-k8s": "mocha --config test/mocha_mongodb.
|
|
155
|
-
"check:
|
|
156
|
-
"check:
|
|
157
|
-
"check:
|
|
158
|
-
"check:
|
|
159
|
-
"check:
|
|
160
|
-
"check:csfle": "mocha --config test/mocha_mongodb.json test/integration/client-side-encryption",
|
|
145
|
+
"check:atlas": "mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts",
|
|
146
|
+
"check:resource-management": "mocha --config test/manual/mocharc.js test/manual/resource_management.test.ts",
|
|
147
|
+
"check:drivers-atlas-testing": "mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts",
|
|
148
|
+
"check:adl": "mocha --config test/mocha_mongodb.js test/manual/atlas-data-lake-testing",
|
|
149
|
+
"check:aws": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts",
|
|
150
|
+
"check:oidc-auth": "mocha --config test/mocha_mongodb.js test/integration/auth/auth.spec.test.ts",
|
|
151
|
+
"check:oidc-test": "mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc.prose.test.ts",
|
|
152
|
+
"check:oidc-azure": "mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc_azure.prose.05.test.ts",
|
|
153
|
+
"check:oidc-gcp": "mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc_gcp.prose.06.test.ts",
|
|
154
|
+
"check:oidc-k8s": "mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc_k8s.prose.07.test.ts",
|
|
155
|
+
"check:kerberos": "nyc mocha --config test/manual/mocharc.js test/manual/kerberos.test.ts",
|
|
156
|
+
"check:tls": "mocha --config test/manual/mocharc.js test/manual/tls_support.test.ts",
|
|
157
|
+
"check:ldap": "nyc mocha --config test/manual/mocharc.js test/manual/ldap.test.ts",
|
|
158
|
+
"check:socks5": "mocha --config test/manual/mocharc.js test/manual/socks5.test.ts",
|
|
159
|
+
"check:csfle": "mocha --config test/mocha_mongodb.js test/integration/client-side-encryption",
|
|
161
160
|
"check:snappy": "mocha test/unit/assorted/snappy.test.js",
|
|
162
161
|
"check:x509": "mocha test/manual/x509_auth.test.ts",
|
|
163
162
|
"fix:eslint": "npm run check:eslint -- --fix",
|
|
@@ -176,4 +175,4 @@
|
|
|
176
175
|
"moduleResolution": "node"
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
|
-
}
|
|
178
|
+
}
|
package/src/change_stream.ts
CHANGED
|
@@ -951,12 +951,10 @@ export class ChangeStream<
|
|
|
951
951
|
|
|
952
952
|
/** @internal */
|
|
953
953
|
private _endStream(): void {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
|
|
954
|
+
this.cursorStream?.removeAllListeners('data');
|
|
955
|
+
this.cursorStream?.removeAllListeners('close');
|
|
956
|
+
this.cursorStream?.removeAllListeners('end');
|
|
957
|
+
this.cursorStream?.destroy();
|
|
960
958
|
this.cursorStream = undefined;
|
|
961
959
|
}
|
|
962
960
|
|
package/src/cmap/connect.ts
CHANGED
|
@@ -427,7 +427,6 @@ export async function makeSocket(options: MakeConnectionOptions): Promise<Stream
|
|
|
427
427
|
throw error;
|
|
428
428
|
} finally {
|
|
429
429
|
socket.setTimeout(0);
|
|
430
|
-
socket.removeAllListeners();
|
|
431
430
|
if (cancellationHandler != null) {
|
|
432
431
|
options.cancellationToken?.removeListener('cancel', cancellationHandler);
|
|
433
432
|
}
|
package/src/cmap/connection.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
HostAddress,
|
|
47
47
|
maxWireVersion,
|
|
48
48
|
type MongoDBNamespace,
|
|
49
|
+
noop,
|
|
49
50
|
now,
|
|
50
51
|
once,
|
|
51
52
|
squashError,
|
|
@@ -229,6 +230,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
|
|
|
229
230
|
|
|
230
231
|
constructor(stream: Stream, options: ConnectionOptions) {
|
|
231
232
|
super();
|
|
233
|
+
this.on('error', noop);
|
|
232
234
|
|
|
233
235
|
this.socket = stream;
|
|
234
236
|
this.id = options.id;
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
kDispose,
|
|
35
35
|
List,
|
|
36
36
|
makeCounter,
|
|
37
|
+
noop,
|
|
37
38
|
now,
|
|
38
39
|
promiseWithResolvers
|
|
39
40
|
} from '../utils';
|
|
@@ -200,6 +201,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
|
|
|
200
201
|
|
|
201
202
|
constructor(server: Server, options: ConnectionPoolOptions) {
|
|
202
203
|
super();
|
|
204
|
+
this.on('error', noop);
|
|
203
205
|
|
|
204
206
|
this.options = Object.freeze({
|
|
205
207
|
connectionType: Connection,
|
package/src/collection.ts
CHANGED
|
@@ -389,7 +389,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
389
389
|
filter: Filter<TSchema>,
|
|
390
390
|
replacement: WithoutId<TSchema>,
|
|
391
391
|
options?: ReplaceOptions
|
|
392
|
-
): Promise<UpdateResult<TSchema
|
|
392
|
+
): Promise<UpdateResult<TSchema>> {
|
|
393
393
|
return await executeOperation(
|
|
394
394
|
this.client,
|
|
395
395
|
new ReplaceOneOperation(
|
|
@@ -966,32 +966,40 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
966
966
|
/**
|
|
967
967
|
* Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
|
|
968
968
|
*
|
|
969
|
+
* The value of `update` can be either:
|
|
970
|
+
* - UpdateFilter<TSchema> - A document that contains update operator expressions,
|
|
971
|
+
* - Document[] - an aggregation pipeline consisting of the following stages:
|
|
972
|
+
* - $addFields and its alias $set
|
|
973
|
+
* - $project and its alias $unset
|
|
974
|
+
* - $replaceRoot and its alias $replaceWith.
|
|
975
|
+
* See the [findAndModify command documentation](https://www.mongodb.com/docs/manual/reference/command/findAndModify) for details.
|
|
976
|
+
*
|
|
969
977
|
* @param filter - The filter used to select the document to update
|
|
970
|
-
* @param update -
|
|
978
|
+
* @param update - The modifications to apply
|
|
971
979
|
* @param options - Optional settings for the command
|
|
972
980
|
*/
|
|
973
981
|
async findOneAndUpdate(
|
|
974
982
|
filter: Filter<TSchema>,
|
|
975
|
-
update: UpdateFilter<TSchema
|
|
983
|
+
update: UpdateFilter<TSchema> | Document[],
|
|
976
984
|
options: FindOneAndUpdateOptions & { includeResultMetadata: true }
|
|
977
985
|
): Promise<ModifyResult<TSchema>>;
|
|
978
986
|
async findOneAndUpdate(
|
|
979
987
|
filter: Filter<TSchema>,
|
|
980
|
-
update: UpdateFilter<TSchema
|
|
988
|
+
update: UpdateFilter<TSchema> | Document[],
|
|
981
989
|
options: FindOneAndUpdateOptions & { includeResultMetadata: false }
|
|
982
990
|
): Promise<WithId<TSchema> | null>;
|
|
983
991
|
async findOneAndUpdate(
|
|
984
992
|
filter: Filter<TSchema>,
|
|
985
|
-
update: UpdateFilter<TSchema
|
|
993
|
+
update: UpdateFilter<TSchema> | Document[],
|
|
986
994
|
options: FindOneAndUpdateOptions
|
|
987
995
|
): Promise<WithId<TSchema> | null>;
|
|
988
996
|
async findOneAndUpdate(
|
|
989
997
|
filter: Filter<TSchema>,
|
|
990
|
-
update: UpdateFilter<TSchema>
|
|
998
|
+
update: UpdateFilter<TSchema> | Document[]
|
|
991
999
|
): Promise<WithId<TSchema> | null>;
|
|
992
1000
|
async findOneAndUpdate(
|
|
993
1001
|
filter: Filter<TSchema>,
|
|
994
|
-
update: UpdateFilter<TSchema
|
|
1002
|
+
update: UpdateFilter<TSchema> | Document[],
|
|
995
1003
|
options?: FindOneAndUpdateOptions
|
|
996
1004
|
): Promise<WithId<TSchema> | ModifyResult<TSchema> | null> {
|
|
997
1005
|
return await executeOperation(
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
type Disposable,
|
|
28
28
|
kDispose,
|
|
29
29
|
type MongoDBNamespace,
|
|
30
|
+
noop,
|
|
30
31
|
squashError
|
|
31
32
|
} from '../utils';
|
|
32
33
|
|
|
@@ -267,6 +268,7 @@ export abstract class AbstractCursor<
|
|
|
267
268
|
options: AbstractCursorOptions & Abortable = {}
|
|
268
269
|
) {
|
|
269
270
|
super();
|
|
271
|
+
this.on('error', noop);
|
|
270
272
|
|
|
271
273
|
if (!client.s.isMongoClient) {
|
|
272
274
|
throw new MongoRuntimeError('Cursor must be constructed with MongoClient');
|
package/src/error.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Document
|
|
1
|
+
import type { Document } from './bson';
|
|
2
2
|
import {
|
|
3
3
|
type ClientBulkWriteError,
|
|
4
4
|
type ClientBulkWriteResult
|
|
5
5
|
} from './operations/client_bulk_write/common';
|
|
6
6
|
import type { ServerType } from './sdam/common';
|
|
7
|
-
import type {
|
|
7
|
+
import type { TopologyVersion } from './sdam/server_description';
|
|
8
8
|
import type { TopologyDescription } from './sdam/topology_description';
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
@@ -355,16 +355,8 @@ export class MongoStalePrimaryError extends MongoRuntimeError {
|
|
|
355
355
|
*
|
|
356
356
|
* @public
|
|
357
357
|
**/
|
|
358
|
-
constructor(
|
|
359
|
-
|
|
360
|
-
maxSetVersion: number | null,
|
|
361
|
-
maxElectionId: ObjectId | null,
|
|
362
|
-
options?: { cause?: Error }
|
|
363
|
-
) {
|
|
364
|
-
super(
|
|
365
|
-
`primary marked stale due to electionId/setVersion mismatch: server setVersion: ${serverDescription.setVersion}, server electionId: ${serverDescription.electionId}, topology setVersion: ${maxSetVersion}, topology electionId: ${maxElectionId}`,
|
|
366
|
-
options
|
|
367
|
-
);
|
|
358
|
+
constructor(message: string, options?: { cause?: Error }) {
|
|
359
|
+
super(message, options);
|
|
368
360
|
}
|
|
369
361
|
|
|
370
362
|
override get name(): string {
|
package/src/gridfs/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type Filter, TypedEventEmitter } from '../mongo_types';
|
|
|
7
7
|
import type { ReadPreference } from '../read_preference';
|
|
8
8
|
import type { Sort } from '../sort';
|
|
9
9
|
import { CSOTTimeoutContext } from '../timeout';
|
|
10
|
-
import { resolveOptions } from '../utils';
|
|
10
|
+
import { noop, resolveOptions } from '../utils';
|
|
11
11
|
import { WriteConcern, type WriteConcernOptions } from '../write_concern';
|
|
12
12
|
import type { FindOptions } from './../operations/find';
|
|
13
13
|
import {
|
|
@@ -87,6 +87,7 @@ export class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents> {
|
|
|
87
87
|
|
|
88
88
|
constructor(db: Db, options?: GridFSBucketOptions) {
|
|
89
89
|
super();
|
|
90
|
+
this.on('error', noop);
|
|
90
91
|
this.setMaxListeners(0);
|
|
91
92
|
const privateOptions = resolveOptions(db, {
|
|
92
93
|
...DEFAULT_GRIDFS_BUCKET_OPTIONS,
|
package/src/mongo_client.ts
CHANGED
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
hostMatchesWildcards,
|
|
58
58
|
isHostMatch,
|
|
59
59
|
type MongoDBNamespace,
|
|
60
|
+
noop,
|
|
60
61
|
ns,
|
|
61
62
|
resolveOptions,
|
|
62
63
|
squashError
|
|
@@ -381,6 +382,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
|
|
|
381
382
|
|
|
382
383
|
constructor(url: string, options?: MongoClientOptions) {
|
|
383
384
|
super();
|
|
385
|
+
this.on('error', noop);
|
|
384
386
|
|
|
385
387
|
this.options = parseOptions(url, this, options);
|
|
386
388
|
|
package/src/mongo_types.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
type MongoLogger
|
|
25
25
|
} from './mongo_logger';
|
|
26
26
|
import type { Sort } from './sort';
|
|
27
|
+
import { noop } from './utils';
|
|
27
28
|
|
|
28
29
|
/** @internal */
|
|
29
30
|
export type TODO_NODE_3286 = any;
|
|
@@ -472,7 +473,12 @@ export class TypedEventEmitter<Events extends EventsDescription> extends EventEm
|
|
|
472
473
|
}
|
|
473
474
|
|
|
474
475
|
/** @public */
|
|
475
|
-
export class CancellationToken extends TypedEventEmitter<{ cancel(): void }> {
|
|
476
|
+
export class CancellationToken extends TypedEventEmitter<{ cancel(): void }> {
|
|
477
|
+
constructor(...args: any[]) {
|
|
478
|
+
super(...args);
|
|
479
|
+
this.on('error', noop);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
476
482
|
|
|
477
483
|
/** @public */
|
|
478
484
|
export type Abortable = {
|
package/src/sdam/monitor.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type Callback,
|
|
14
14
|
type EventEmitterWithState,
|
|
15
15
|
makeStateMachine,
|
|
16
|
+
noop,
|
|
16
17
|
now,
|
|
17
18
|
ns
|
|
18
19
|
} from '../utils';
|
|
@@ -102,6 +103,7 @@ export class Monitor extends TypedEventEmitter<MonitorEvents> {
|
|
|
102
103
|
|
|
103
104
|
constructor(server: Server, options: MonitorOptions) {
|
|
104
105
|
super();
|
|
106
|
+
this.on('error', noop);
|
|
105
107
|
|
|
106
108
|
this.server = server;
|
|
107
109
|
this.connection = null;
|
package/src/sdam/server.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
makeStateMachine,
|
|
48
48
|
maxWireVersion,
|
|
49
49
|
type MongoDBNamespace,
|
|
50
|
+
noop,
|
|
50
51
|
supportsRetryableWrites
|
|
51
52
|
} from '../utils';
|
|
52
53
|
import { throwIfWriteConcernError } from '../write_concern';
|
|
@@ -142,6 +143,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
142
143
|
*/
|
|
143
144
|
constructor(topology: Topology, description: ServerDescription, options: ServerOptions) {
|
|
144
145
|
super();
|
|
146
|
+
this.on('error', noop);
|
|
145
147
|
|
|
146
148
|
this.serverApi = options.serverApi;
|
|
147
149
|
|
package/src/sdam/srv_polling.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { clearTimeout, setTimeout } from 'timers';
|
|
|
3
3
|
|
|
4
4
|
import { MongoRuntimeError } from '../error';
|
|
5
5
|
import { TypedEventEmitter } from '../mongo_types';
|
|
6
|
-
import { checkParentDomainMatch, HostAddress, squashError } from '../utils';
|
|
6
|
+
import { checkParentDomainMatch, HostAddress, noop, squashError } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
@@ -49,6 +49,7 @@ export class SrvPoller extends TypedEventEmitter<SrvPollerEvents> {
|
|
|
49
49
|
|
|
50
50
|
constructor(options: SrvPollerOptions) {
|
|
51
51
|
super();
|
|
52
|
+
this.on('error', noop);
|
|
52
53
|
|
|
53
54
|
if (!options || !options.srvHost) {
|
|
54
55
|
throw new MongoRuntimeError('Options for SrvPoller must exist and include srvHost');
|
package/src/sdam/topology.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
kDispose,
|
|
45
45
|
List,
|
|
46
46
|
makeStateMachine,
|
|
47
|
+
noop,
|
|
47
48
|
now,
|
|
48
49
|
ns,
|
|
49
50
|
promiseWithResolvers,
|
|
@@ -248,6 +249,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
|
|
|
248
249
|
options: TopologyOptions
|
|
249
250
|
) {
|
|
250
251
|
super();
|
|
252
|
+
this.on('error', noop);
|
|
251
253
|
|
|
252
254
|
this.client = client;
|
|
253
255
|
// Options should only be undefined in tests, MongoClient will always have defined options
|
|
@@ -376,6 +376,19 @@ function updateRsFromPrimary(
|
|
|
376
376
|
maxSetVersion: number | null = null,
|
|
377
377
|
maxElectionId: ObjectId | null = null
|
|
378
378
|
): [TopologyType, string | null, number | null, ObjectId | null] {
|
|
379
|
+
const setVersionElectionIdMismatch = (
|
|
380
|
+
serverDescription: ServerDescription,
|
|
381
|
+
maxSetVersion: number | null,
|
|
382
|
+
maxElectionId: ObjectId | null
|
|
383
|
+
) => {
|
|
384
|
+
return (
|
|
385
|
+
`primary marked stale due to electionId/setVersion mismatch:` +
|
|
386
|
+
` server setVersion: ${serverDescription.setVersion},` +
|
|
387
|
+
` server electionId: ${serverDescription.electionId},` +
|
|
388
|
+
` topology setVersion: ${maxSetVersion},` +
|
|
389
|
+
` topology electionId: ${maxElectionId}`
|
|
390
|
+
);
|
|
391
|
+
};
|
|
379
392
|
setName = setName || serverDescription.setName;
|
|
380
393
|
if (setName !== serverDescription.setName) {
|
|
381
394
|
serverDescriptions.delete(serverDescription.address);
|
|
@@ -401,7 +414,9 @@ function updateRsFromPrimary(
|
|
|
401
414
|
serverDescriptions.set(
|
|
402
415
|
serverDescription.address,
|
|
403
416
|
new ServerDescription(serverDescription.address, undefined, {
|
|
404
|
-
error: new MongoStalePrimaryError(
|
|
417
|
+
error: new MongoStalePrimaryError(
|
|
418
|
+
setVersionElectionIdMismatch(serverDescription, maxSetVersion, maxElectionId)
|
|
419
|
+
)
|
|
405
420
|
})
|
|
406
421
|
);
|
|
407
422
|
|
|
@@ -419,7 +434,9 @@ function updateRsFromPrimary(
|
|
|
419
434
|
serverDescriptions.set(
|
|
420
435
|
serverDescription.address,
|
|
421
436
|
new ServerDescription(serverDescription.address, undefined, {
|
|
422
|
-
error: new MongoStalePrimaryError(
|
|
437
|
+
error: new MongoStalePrimaryError(
|
|
438
|
+
setVersionElectionIdMismatch(serverDescription, maxSetVersion, maxElectionId)
|
|
439
|
+
)
|
|
423
440
|
})
|
|
424
441
|
);
|
|
425
442
|
|
|
@@ -445,7 +462,9 @@ function updateRsFromPrimary(
|
|
|
445
462
|
serverDescriptions.set(
|
|
446
463
|
address,
|
|
447
464
|
new ServerDescription(server.address, undefined, {
|
|
448
|
-
error: new MongoStalePrimaryError(
|
|
465
|
+
error: new MongoStalePrimaryError(
|
|
466
|
+
'primary marked stale due to discovery of newer primary'
|
|
467
|
+
)
|
|
449
468
|
})
|
|
450
469
|
);
|
|
451
470
|
|
package/src/sessions.ts
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
isPromiseLike,
|
|
44
44
|
List,
|
|
45
45
|
maxWireVersion,
|
|
46
|
+
noop,
|
|
46
47
|
now,
|
|
47
48
|
squashError,
|
|
48
49
|
uuidV4
|
|
@@ -161,6 +162,7 @@ export class ClientSession
|
|
|
161
162
|
clientOptions: MongoOptions
|
|
162
163
|
) {
|
|
163
164
|
super();
|
|
165
|
+
this.on('error', noop);
|
|
164
166
|
|
|
165
167
|
if (client == null) {
|
|
166
168
|
// TODO(NODE-3483)
|
package/src/utils.ts
CHANGED
|
@@ -531,9 +531,11 @@ export function resolveOptions<T extends CommandOperationOptions>(
|
|
|
531
531
|
if (writeConcern) {
|
|
532
532
|
if (timeoutMS != null) {
|
|
533
533
|
writeConcern = WriteConcern.fromOptions({
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
writeConcern: {
|
|
535
|
+
...writeConcern,
|
|
536
|
+
wtimeout: undefined,
|
|
537
|
+
wtimeoutMS: undefined
|
|
538
|
+
}
|
|
537
539
|
});
|
|
538
540
|
}
|
|
539
541
|
result.writeConcern = writeConcern;
|