mongodb 6.13.0 → 6.13.1-dev.20250221.sha.21f2cb91
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 +3 -2
- 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/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 +3 -2
- 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 +1 -1
- 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
|
@@ -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;
|