Skip to content

Commit 8483054

Browse files
authored
Merge branch 'main' into NODE-7298
2 parents 9837a8b + ae2e037 commit 8483054

21 files changed

Lines changed: 150 additions & 152 deletions

.evergreen/config.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,19 +1877,6 @@ tasks:
18771877
- func: install dependencies
18781878
- func: bootstrap mongo-orchestration
18791879
- func: check resource management feature integration
1880-
- name: check-types-typescript-next
1881-
tags:
1882-
- check-types-typescript-next
1883-
- typescript-compilation
1884-
commands:
1885-
- command: expansions.update
1886-
type: setup
1887-
params:
1888-
updates:
1889-
- {key: NODE_LTS_VERSION, value: 20.19.0}
1890-
- {key: TS_VERSION, value: next}
1891-
- func: install dependencies
1892-
- func: check types
18931880
- name: check-types-typescript-current
18941881
tags:
18951882
- check-types-typescript-current

.evergreen/generate_evergreen_tasks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ function* makeTypescriptTasks() {
532532
};
533533
}
534534

535-
yield makeCheckTypesTask('next');
535+
// TODO(NODE-7233): unskip ts@next tests once we adopt Typescript 6.0.
536+
// yield makeCheckTypesTask('next');
536537
yield makeCheckTypesTask('current');
537538
yield makeCheckTypesTask('5.6');
538539

etc/sdam_viz.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// npx ts-node etc/sdam_viz.js -h
66

77
const { MongoClient } = require('../src');
8-
const { now, calculateDurationInMs, arrayStrictEqual, errorStrictEqual } = require('../src/utils');
8+
const { calculateDurationInMs, arrayStrictEqual, errorStrictEqual, processTimeMS } = require('../src/utils');
99

1010
const util = require('util');
1111
const chalk = require('chalk');
@@ -207,7 +207,7 @@ async function scheduleWriteWorkload(client) {
207207
const currentWriteWorkload = writeWorkloadCounter++;
208208

209209
try {
210-
const start = now();
210+
const start = processTimeMS();
211211
await client.db('test').collection('test').insertOne({ a: 42 });
212212
averageWriteMS = 0.2 * calculateDurationInMs(start) + 0.8 * averageWriteMS;
213213

src/cmap/auth/mongo_credentials.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const DEFAULT_ALLOWED_HOSTS = [
4545
'*.mongodbgov.net',
4646
'localhost',
4747
'127.0.0.1',
48-
'::1'
48+
'::1',
49+
'*.mongo.com'
4950
];
5051

5152
/** Error for when the token audience is missing in the environment. */

src/cmap/connection.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import {
4747
maxWireVersion,
4848
type MongoDBNamespace,
4949
noop,
50-
now,
5150
once,
51+
processTimeMS,
5252
squashError,
5353
uuidV4
5454
} from '../utils';
@@ -241,7 +241,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
241241

242242
this.description = new StreamDescription(this.address, options);
243243
this.generation = options.generation;
244-
this.lastUseTime = now();
244+
this.lastUseTime = processTimeMS();
245245

246246
this.messageStream = this.socket
247247
.on('error', this.onSocketError.bind(this))
@@ -299,7 +299,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
299299
}
300300

301301
public markAvailable(): void {
302-
this.lastUseTime = now();
302+
this.lastUseTime = processTimeMS();
303303
}
304304

305305
private onSocketError(cause: Error) {
@@ -510,7 +510,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
510510
const message = this.prepareCommand(ns.db, command, options);
511511
let started = 0;
512512
if (this.shouldEmitAndLogCommand) {
513-
started = now();
513+
started = processTimeMS();
514514
this.emitAndLogCommand(
515515
this.monitorCommands,
516516
Connection.COMMAND_STARTED,

src/cmap/connection_pool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
List,
3737
makeCounter,
3838
noop,
39-
now,
39+
processTimeMS,
4040
promiseWithResolvers
4141
} from '../utils';
4242
import { connect } from './connect';
@@ -319,7 +319,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
319319
* explicitly destroyed by the new owner.
320320
*/
321321
async checkOut(options: { timeoutContext: TimeoutContext } & Abortable): Promise<Connection> {
322-
const checkoutTime = now();
322+
const checkoutTime = processTimeMS();
323323
this.emitAndLog(
324324
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
325325
new ConnectionCheckOutStartedEvent(this)
@@ -616,7 +616,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
616616

617617
this.pending++;
618618
// This is our version of a "virtual" no-I/O connection as the spec requires
619-
const connectionCreatedTime = now();
619+
const connectionCreatedTime = processTimeMS();
620620
this.emitAndLog(
621621
ConnectionPool.CONNECTION_CREATED,
622622
new ConnectionCreatedEvent(this, { id: connectOptions.id })

src/cmap/connection_pool_events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
CONNECTION_READY
1414
} from '../constants';
1515
import type { MongoError } from '../error';
16-
import { now } from '../utils';
16+
import { processTimeMS } from '../utils';
1717
import type { Connection } from './connection';
1818
import type { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
1919

@@ -145,7 +145,7 @@ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
145145
/** @internal */
146146
constructor(pool: ConnectionPool, connection: Connection, connectionCreatedEventTime: number) {
147147
super(pool);
148-
this.durationMS = now() - connectionCreatedEventTime;
148+
this.durationMS = processTimeMS() - connectionCreatedEventTime;
149149
this.connectionId = connection.id;
150150
}
151151
}
@@ -224,7 +224,7 @@ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent
224224
error?: MongoError
225225
) {
226226
super(pool);
227-
this.durationMS = now() - checkoutTime;
227+
this.durationMS = processTimeMS() - checkoutTime;
228228
this.reason = reason;
229229
this.error = error;
230230
}
@@ -252,7 +252,7 @@ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
252252
/** @internal */
253253
constructor(pool: ConnectionPool, connection: Connection, checkoutTime: number) {
254254
super(pool);
255-
this.durationMS = now() - checkoutTime;
255+
this.durationMS = processTimeMS() - checkoutTime;
256256
this.connectionId = connection.id;
257257
}
258258
}

src/db.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ export class Db {
394394
toCollection,
395395
resolveOptions(undefined, {
396396
...options,
397-
new_collection: true,
398397
readPreference: ReadPreference.primary
399398
})
400399
) as TODO_NODE_3286

src/error.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,13 +1528,7 @@ export function isNodeShuttingDownError(err: MongoError): boolean {
15281528
*
15291529
* @see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.md#not-writable-primary-and-node-is-recovering
15301530
*/
1531-
export function isSDAMUnrecoverableError(error: MongoError): boolean {
1532-
// NOTE: null check is here for a strictly pre-CMAP world, a timeout or
1533-
// close event are considered unrecoverable
1534-
if (error instanceof MongoParseError || error == null) {
1535-
return true;
1536-
}
1537-
1531+
export function isStateChangeError(error: MongoError): boolean {
15381532
return isRecoveringError(error) || isNotWritablePrimaryError(error);
15391533
}
15401534

src/operations/rename.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import { Aspect, defineAspects } from './operation';
1111
export interface RenameOptions extends Omit<CommandOperationOptions, 'rawData'> {
1212
/** Drop the target name collection if it previously exists. */
1313
dropTarget?: boolean;
14-
/** Unclear */
14+
/**
15+
* @deprecated
16+
*
17+
* This option has been dead code since at least Node driver version 4.x. It will
18+
* be removed in a future major release.
19+
*/
1520
new_collection?: boolean;
1621
}
1722

0 commit comments

Comments
 (0)