Skip to content

Commit e2c124e

Browse files
committed
chore: address comments
1 parent 2102da2 commit e2c124e

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

src/cmap/connection_pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
620620
cancellationToken: this.cancellationToken,
621621
mongoLogger: this.mongoLogger,
622622
authProviders: this.server.topology.client.s.authProviders,
623-
extendedMetadata: this.server.topology.client.options?.extendedMetadata
623+
extendedMetadata: this.server.topology.client.options.extendedMetadata
624624
};
625625

626626
this.pending++;

src/cmap/handshake/client_metadata.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as os from 'os';
22
import * as process from 'process';
33

44
import { BSON, type Document, Int32 } from '../../bson';
5-
import { MongoInvalidArgumentError } from '../../error';
5+
import { MongoInvalidArgumentError, MongoRuntimeError } from '../../error';
66
import type { MongoOptions } from '../../mongo_client';
77
import { fileIsAccessible } from '../../utils';
88

@@ -122,15 +122,19 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
122122
version: version.length > 0 ? `${NODE_DRIVER_VERSION}|${version}` : NODE_DRIVER_VERSION
123123
};
124124

125+
if (options.additionalDriverInfo == null) {
126+
throw new MongoRuntimeError(
127+
'Client options `additionalDriverInfo` must always default to an empty array'
128+
);
129+
}
130+
125131
// This is where we handle additional driver info added after client construction.
126-
if (options.additionalDriverInfo?.length > 0) {
127-
for (const { name: n = '', version: v = '' } of options.additionalDriverInfo) {
128-
if (n.length > 0) {
129-
driverInfo.name = `${driverInfo.name}|${n}`;
130-
}
131-
if (v.length > 0) {
132-
driverInfo.version = `${driverInfo.version}|${v}`;
133-
}
132+
for (const { name: n = '', version: v = '' } of options.additionalDriverInfo) {
133+
if (n.length > 0) {
134+
driverInfo.name = `${driverInfo.name}|${n}`;
135+
}
136+
if (v.length > 0) {
137+
driverInfo.version = `${driverInfo.version}|${v}`;
134138
}
135139
}
136140

@@ -145,11 +149,9 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
145149
runtimeInfo = `${runtimeInfo}|${platform}`;
146150
}
147151

148-
if (options.additionalDriverInfo?.length > 0) {
149-
for (const { platform: p = '' } of options.additionalDriverInfo) {
150-
if (p.length > 0) {
151-
runtimeInfo = `${runtimeInfo}|${p}`;
152-
}
152+
for (const { platform: p = '' } of options.additionalDriverInfo) {
153+
if (p.length > 0) {
154+
runtimeInfo = `${runtimeInfo}|${p}`;
153155
}
154156
}
155157

test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('Client Metadata Update Prose Tests', function () {
204204
sinon.restore();
205205
});
206206

207-
describe('Test 2: Multiple Successive Metadata Updates', function () {
207+
describe('Test 1: Test that the driver updates metadata', function () {
208208
let initialClientMetadata;
209209
let updatedClientMetadata;
210210

@@ -279,13 +279,15 @@ describe('Client Metadata Update Prose Tests', function () {
279279
? `${initialClientMetadata.platform}|${platform}`
280280
: initialClientMetadata.platform
281281
);
282+
// - All other subfields in the client document remain unchanged from initialClientMetadata.
283+
// (Note os is the only one getting set in these tests)
282284
expect(updatedClientMetadata.os).to.deep.equal(initialClientMetadata.os);
283285
});
284286
});
285287
}
286288
});
287289

288-
describe('Test 1: Test that the driver updates metadata', function () {
290+
describe('Test 2: Multiple Successive Metadata Updates', function () {
289291
let initialClientMetadata;
290292
let updatedClientMetadata;
291293

@@ -355,6 +357,8 @@ describe('Client Metadata Update Prose Tests', function () {
355357
? `${initialClientMetadata.platform}|${platform}`
356358
: initialClientMetadata.platform
357359
);
360+
// - All other subfields in the client document remain unchanged from initialClientMetadata.
361+
// (Note os is the only one getting set in these tests)
358362
expect(updatedClientMetadata.os).to.deep.equal(initialClientMetadata.os);
359363
});
360364
});

test/spec/connection-monitoring-and-pooling/cmap-format/pool-create-min-size-error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"data": {
1616
"failCommands": [
17-
"ismaster",
17+
"isMaster",
1818
"hello"
1919
],
2020
"closeConnection": true,

test/tools/cmap_spec_runner.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ async function runCmapTest(test: CmapTest, threadContext: ThreadContext) {
376376
delete poolOptions.backgroundThreadIntervalMS;
377377
}
378378

379-
//const metadata = makeClientMetadata({ appName: poolOptions.appName });
380-
//const extendedMetadata = addContainerMetadata(metadata);
381379
delete poolOptions.appName;
382380

383381
const operations = test.operations;

0 commit comments

Comments
 (0)