Skip to content

Commit 7a504fc

Browse files
Merge branch 'main' into NODE-5920
2 parents 05b3797 + e5582ed commit 7a504fc

File tree

198 files changed

+11001
-1254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+11001
-1254
lines changed

.evergreen/config.in.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ functions:
11021102
env:
11031103
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
11041104
MONGODB_URI: ${MONGODB_URI}
1105+
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
11051106
binary: bash
11061107
args:
11071108
- ${PROJECT_DIRECTORY}/.evergreen/run-benchmarks.sh
@@ -1146,7 +1147,7 @@ tasks:
11461147
- func: bootstrap kms servers
11471148
- func: "run serverless tests"
11481149

1149-
- name: run-spec-benchmark-tests-node-18-server-6.0
1150+
- name: run-spec-benchmark-tests-node-server
11501151
tags:
11511152
- run-spec-benchmark-tests
11521153
- performance
@@ -1156,8 +1157,7 @@ tasks:
11561157
type: setup
11571158
params:
11581159
updates:
1159-
- { key: NODE_LTS_VERSION, value: v18.16.0 }
1160-
- { key: NPM_VERSION, value: "9" }
1160+
- { key: NODE_LTS_VERSION, value: v22.11.0 }
11611161
- { key: VERSION, value: v6.0-perf }
11621162
- { key: TOPOLOGY, value: server }
11631163
- { key: AUTH, value: noauth }
@@ -1615,4 +1615,4 @@ buildvariants:
16151615
display_name: Performance Test
16161616
run_on: rhel90-dbx-perf-large
16171617
tasks:
1618-
- run-spec-benchmark-tests-node-18-server-6.0
1618+
- run-spec-benchmark-tests-node-server

.evergreen/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ functions:
10641064
env:
10651065
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
10661066
MONGODB_URI: ${MONGODB_URI}
1067+
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
10671068
binary: bash
10681069
args:
10691070
- ${PROJECT_DIRECTORY}/.evergreen/run-benchmarks.sh
@@ -1107,7 +1108,7 @@ tasks:
11071108
- func: install dependencies
11081109
- func: bootstrap kms servers
11091110
- func: run serverless tests
1110-
- name: run-spec-benchmark-tests-node-18-server-6.0
1111+
- name: run-spec-benchmark-tests-node-server
11111112
tags:
11121113
- run-spec-benchmark-tests
11131114
- performance
@@ -1117,8 +1118,7 @@ tasks:
11171118
type: setup
11181119
params:
11191120
updates:
1120-
- {key: NODE_LTS_VERSION, value: v18.16.0}
1121-
- {key: NPM_VERSION, value: '9'}
1121+
- {key: NODE_LTS_VERSION, value: v22.11.0}
11221122
- {key: VERSION, value: v6.0-perf}
11231123
- {key: TOPOLOGY, value: server}
11241124
- {key: AUTH, value: noauth}
@@ -4546,7 +4546,7 @@ buildvariants:
45464546
display_name: Performance Test
45474547
run_on: rhel90-dbx-perf-large
45484548
tasks:
4549-
- run-spec-benchmark-tests-node-18-server-6.0
4549+
- run-spec-benchmark-tests-node-server
45504550
- name: rhel80-large-gallium
45514551
display_name: rhel8 Node16
45524552
run_on: rhel80-large

.evergreen/run-benchmarks.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#! /bin/bash
22

3+
set -o errexit
4+
set -o xtrace
5+
set -o nounset
6+
37
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
48

59
export MONGODB_URI=$MONGODB_URI

.evergreen/run-resource-management-feature-integration.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
44

5+
echo "node: $(node --version)"
6+
echo "npm: $(npm --version)"
7+
58
echo "Building driver..."
69
npm pack
710
echo "Building driver...finished."

.evergreen/run-serverless-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ npx mocha \
2020
test/integration/sessions/sessions.prose.test.ts \
2121
test/integration/sessions/sessions.test.ts \
2222
test/integration/transactions/transactions.spec.test.ts \
23+
test/integration/transactions-convenient-api/transactions-convenient-api.spec.test.ts \
2324
test/integration/transactions/transactions.test.ts \
2425
test/integration/versioned-api/versioned_api.spec.test.ts \
2526
test/integration/load-balancers/load_balancers.spec.test.ts \

etc/notes/errors.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Children of `MongoError` include:
6767
### `MongoDriverError`
6868

6969
This class represents errors which originate in the driver itself or when the user incorrectly uses the driver. This class should **never** be directly instantiated.
70-
Its children are the main classes of errors that most users will interact with: [**`MongoAPIError`**](#MongoAPIError) and [**`MongoRuntimeError`**](#MongoRuntimeError).
70+
Its children are the main classes of errors that most users will interact with: [**`MongoAPIError`**](#MongoAPIError), [**`MongoRuntimeError`**](#MongoRuntimeError) and [**`MongoOperationTimeoutError`**](#MongoOperationTimeoutError).
7171

7272
### `MongoAPIError`
7373

@@ -109,6 +109,12 @@ This class should **never** be directly instantiated.
109109
| **MongoGridFSChunkError** | Thrown when a malformed or invalid chunk is encountered when reading from a GridFS Stream. |
110110
| **MongoUnexpectedServerResponseError** | Thrown when the driver receives a **parsable** response it did not expect from the server. |
111111

112+
### `MongoOperationTimeoutError`
113+
114+
The `MongoOperationTimeoutError` class represents an error that occurs when an operation could not be completed within the specified `timeoutMS`.
115+
It is generated by the driver in support of the "client side operation timeout" feature and inherits from `MongoDriverError`.
116+
When `timeoutMS` is enabled `MongoServerErrors` relating to `MaxTimeExpired` errors will be converted to `MongoOperationTimeoutError`.
117+
112118
### MongoUnexpectedServerResponseError
113119

114120
Intended for the scenario where the MongoDB returns an unexpected response in relation to some state the driver is in.

package-lock.json

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"mocha": "^10.4.0",
9898
"mocha-sinon": "^2.1.2",
9999
"mongodb-client-encryption": "^6.1.0",
100-
"mongodb-legacy": "^6.1.0",
100+
"mongodb-legacy": "^6.1.3",
101101
"nyc": "^15.1.0",
102102
"prettier": "^3.3.3",
103103
"semver": "^7.6.3",

src/admin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export class Admin {
7878
new RunAdminCommandOperation(command, {
7979
...resolveBSONOptions(options),
8080
session: options?.session,
81-
readPreference: options?.readPreference
81+
readPreference: options?.readPreference,
82+
timeoutMS: options?.timeoutMS ?? this.s.db.timeoutMS
8283
})
8384
);
8485
}
@@ -154,7 +155,10 @@ export class Admin {
154155
* @param options - Optional settings for the command
155156
*/
156157
async listDatabases(options?: ListDatabasesOptions): Promise<ListDatabasesResult> {
157-
return await executeOperation(this.s.db.client, new ListDatabasesOperation(this.s.db, options));
158+
return await executeOperation(
159+
this.s.db.client,
160+
new ListDatabasesOperation(this.s.db, { timeoutMS: this.s.db.timeoutMS, ...options })
161+
);
158162
}
159163

160164
/**

src/bulk/common.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { makeUpdateStatement, UpdateOperation, type UpdateStatement } from '../o
1919
import type { Server } from '../sdam/server';
2020
import type { Topology } from '../sdam/topology';
2121
import type { ClientSession } from '../sessions';
22+
import { type TimeoutContext } from '../timeout';
2223
import {
2324
applyRetryableWrites,
2425
getTopology,
@@ -500,7 +501,7 @@ export function mergeBatchResults(
500501

501502
async function executeCommands(
502503
bulkOperation: BulkOperationBase,
503-
options: BulkWriteOptions
504+
options: BulkWriteOptions & { timeoutContext?: TimeoutContext | null }
504505
): Promise<BulkWriteResult> {
505506
if (bulkOperation.s.batches.length === 0) {
506507
return new BulkWriteResult(bulkOperation.s.bulkResult, bulkOperation.isOrdered);
@@ -551,7 +552,11 @@ async function executeCommands(
551552
let thrownError = null;
552553
let result;
553554
try {
554-
result = await executeOperation(bulkOperation.s.collection.client, operation);
555+
result = await executeOperation(
556+
bulkOperation.s.collection.client,
557+
operation,
558+
finalOptions.timeoutContext
559+
);
555560
} catch (error) {
556561
thrownError = error;
557562
}
@@ -842,6 +847,9 @@ export interface BulkWriteOptions extends CommandOperationOptions {
842847
forceServerObjectId?: boolean;
843848
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
844849
let?: Document;
850+
851+
/** @internal */
852+
timeoutContext?: TimeoutContext;
845853
}
846854

847855
/**
@@ -862,15 +870,19 @@ export class BulkWriteShimOperation extends AbstractOperation {
862870
return 'bulkWrite' as const;
863871
}
864872

865-
async execute(_server: Server, session: ClientSession | undefined): Promise<any> {
873+
async execute(
874+
_server: Server,
875+
session: ClientSession | undefined,
876+
timeoutContext: TimeoutContext
877+
): Promise<any> {
866878
if (this.options.session == null) {
867879
// An implicit session could have been created by 'executeOperation'
868880
// So if we stick it on finalOptions here, each bulk operation
869881
// will use this same session, it'll be passed in the same way
870882
// an explicit session would be
871883
this.options.session = session;
872884
}
873-
return await executeCommands(this.bulkOperation, this.options);
885+
return await executeCommands(this.bulkOperation, { ...this.options, timeoutContext });
874886
}
875887
}
876888

@@ -1199,7 +1211,7 @@ export abstract class BulkOperationBase {
11991211
const finalOptions = { ...this.s.options, ...options };
12001212
const operation = new BulkWriteShimOperation(this, finalOptions);
12011213

1202-
return await executeOperation(this.s.collection.client, operation);
1214+
return await executeOperation(this.s.collection.client, operation, finalOptions.timeoutContext);
12031215
}
12041216

12051217
/**

0 commit comments

Comments
 (0)