Skip to content

Commit 8e2b0cc

Browse files
authored
fix(NODE-3792): remove offensive language throughout the codebase (#3091)
1 parent c3256c4 commit 8e2b0cc

21 files changed

+140
-142
lines changed

src/bulk/common.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ export abstract class BulkOperationBase {
940940

941941
const topology = getTopology(collection);
942942
options = options == null ? {} : options;
943-
// TODO Bring from driver information in isMaster
943+
// TODO Bring from driver information in hello
944944
// Get the namespace for the write operations
945945
const namespace = collection.s.namespace;
946946
// Used to mark operation as executed
@@ -950,16 +950,15 @@ export abstract class BulkOperationBase {
950950
const currentOp = undefined;
951951

952952
// Set max byte size
953-
const isMaster = topology.lastIsMaster();
953+
const hello = topology.lastHello();
954954

955955
// If we have autoEncryption on, batch-splitting must be done on 2mb chunks, but single documents
956956
// over 2mb are still allowed
957957
const usingAutoEncryption = !!(topology.s.options && topology.s.options.autoEncrypter);
958958
const maxBsonObjectSize =
959-
isMaster && isMaster.maxBsonObjectSize ? isMaster.maxBsonObjectSize : 1024 * 1024 * 16;
959+
hello && hello.maxBsonObjectSize ? hello.maxBsonObjectSize : 1024 * 1024 * 16;
960960
const maxBatchSizeBytes = usingAutoEncryption ? 1024 * 1024 * 2 : maxBsonObjectSize;
961-
const maxWriteBatchSize =
962-
isMaster && isMaster.maxWriteBatchSize ? isMaster.maxWriteBatchSize : 1000;
961+
const maxWriteBatchSize = hello && hello.maxWriteBatchSize ? hello.maxWriteBatchSize : 1000;
963962

964963
// Calculates the largest possible size of an Array key, represented as a BSON string
965964
// element. This calculation:

src/change_stream.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface ResumeOptions {
7171
}
7272

7373
/**
74-
* Represents the logical starting point for a new or resuming {@link https://docs.mongodb.com/master/changeStreams/#change-stream-resume-token| Change Stream} on the server.
74+
* Represents the logical starting point for a new or resuming {@link https://docs.mongodb.com/manual/changeStreams/#std-label-change-stream-resume| Change Stream} on the server.
7575
* @public
7676
*/
7777
export type ResumeToken = unknown;
@@ -98,9 +98,9 @@ export interface ChangeStreamOptions extends AggregateOptions {
9898
fullDocument?: string;
9999
/** The maximum amount of time for the server to wait on new documents to satisfy a change stream query. */
100100
maxAwaitTimeMS?: number;
101-
/** Allows you to start a changeStream after a specified event. See {@link https://docs.mongodb.com/master/changeStreams/#resumeafter-for-change-streams|ChangeStream documentation}. */
101+
/** Allows you to start a changeStream after a specified event. See {@link https://docs.mongodb.com/manual/changeStreams/#resumeafter-for-change-streams|ChangeStream documentation}. */
102102
resumeAfter?: ResumeToken;
103-
/** Similar to resumeAfter, but will allow you to start after an invalidated event. See {@link https://docs.mongodb.com/master/changeStreams/#startafter-for-change-streams|ChangeStream documentation}. */
103+
/** Similar to resumeAfter, but will allow you to start after an invalidated event. See {@link https://docs.mongodb.com/manual/changeStreams/#startafter-for-change-streams|ChangeStream documentation}. */
104104
startAfter?: ResumeToken;
105105
/** Will start the changeStream after the specified operationTime. */
106106
startAtOperationTime?: OperationTime;

src/cmap/auth/mongo_credentials.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import { MongoAPIError, MongoMissingCredentialsError } from '../../error';
55
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './providers';
66

77
// https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst
8-
function getDefaultAuthMechanism(ismaster?: Document): AuthMechanism {
9-
if (ismaster) {
10-
// If ismaster contains saslSupportedMechs, use scram-sha-256
8+
function getDefaultAuthMechanism(hello?: Document): AuthMechanism {
9+
if (hello) {
10+
// If hello contains saslSupportedMechs, use scram-sha-256
1111
// if it is available, else scram-sha-1
12-
if (Array.isArray(ismaster.saslSupportedMechs)) {
13-
return ismaster.saslSupportedMechs.includes(AuthMechanism.MONGODB_SCRAM_SHA256)
12+
if (Array.isArray(hello.saslSupportedMechs)) {
13+
return hello.saslSupportedMechs.includes(AuthMechanism.MONGODB_SCRAM_SHA256)
1414
? AuthMechanism.MONGODB_SCRAM_SHA256
1515
: AuthMechanism.MONGODB_SCRAM_SHA1;
1616
}
1717

1818
// Fallback to legacy selection method. If wire version >= 3, use scram-sha-1
19-
if (ismaster.maxWireVersion >= 3) {
19+
if (hello.maxWireVersion >= 3) {
2020
return AuthMechanism.MONGODB_SCRAM_SHA1;
2121
}
2222
}
@@ -107,16 +107,16 @@ export class MongoCredentials {
107107
* If the authentication mechanism is set to "default", resolves the authMechanism
108108
* based on the server version and server supported sasl mechanisms.
109109
*
110-
* @param ismaster - An ismaster response from the server
110+
* @param hello - A hello response from the server
111111
*/
112-
resolveAuthMechanism(ismaster?: Document): MongoCredentials {
112+
resolveAuthMechanism(hello?: Document): MongoCredentials {
113113
// If the mechanism is not "default", then it does not need to be resolved
114114
if (this.mechanism.match(/DEFAULT/i)) {
115115
return new MongoCredentials({
116116
username: this.username,
117117
password: this.password,
118118
source: this.source,
119-
mechanism: getDefaultAuthMechanism(ismaster),
119+
mechanism: getDefaultAuthMechanism(hello),
120120
mechanismProperties: this.mechanismProperties
121121
});
122122
}

src/cmap/command_monitoring_events.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Document, ObjectId } from '../bson';
2+
import { LEGACY_HELLO_COMMAND, LEGACY_HELLO_COMMAND_CAMEL_CASE } from '../constants';
23
import { calculateDurationInMs, deepCopy } from '../utils';
34
import { GetMore, KillCursor, Msg, WriteProtocolMessageType } from './commands';
45
import type { Connection } from './connection';
@@ -161,7 +162,7 @@ const SENSITIVE_COMMANDS = new Set([
161162
'copydb'
162163
]);
163164

164-
const HELLO_COMMANDS = new Set(['hello', 'ismaster', 'isMaster']);
165+
const HELLO_COMMANDS = new Set(['hello', LEGACY_HELLO_COMMAND, LEGACY_HELLO_COMMAND_CAMEL_CASE]);
165166

166167
// helper methods
167168
const extractCommandName = (commandDoc: Document) => Object.keys(commandDoc)[0];

src/cmap/connect.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as tls from 'tls';
66

77
import type { Document } from '../bson';
88
import { Int32 } from '../bson';
9+
import { LEGACY_HELLO_COMMAND } from '../constants';
910
import {
1011
AnyError,
1112
MongoCompatibilityError,
@@ -70,29 +71,29 @@ export function connect(options: ConnectionOptions, callback: Callback<Connectio
7071
});
7172
}
7273

73-
function checkSupportedServer(ismaster: Document, options: ConnectionOptions) {
74+
function checkSupportedServer(hello: Document, options: ConnectionOptions) {
7475
const serverVersionHighEnough =
75-
ismaster &&
76-
(typeof ismaster.maxWireVersion === 'number' || ismaster.maxWireVersion instanceof Int32) &&
77-
ismaster.maxWireVersion >= MIN_SUPPORTED_WIRE_VERSION;
76+
hello &&
77+
(typeof hello.maxWireVersion === 'number' || hello.maxWireVersion instanceof Int32) &&
78+
hello.maxWireVersion >= MIN_SUPPORTED_WIRE_VERSION;
7879
const serverVersionLowEnough =
79-
ismaster &&
80-
(typeof ismaster.minWireVersion === 'number' || ismaster.minWireVersion instanceof Int32) &&
81-
ismaster.minWireVersion <= MAX_SUPPORTED_WIRE_VERSION;
80+
hello &&
81+
(typeof hello.minWireVersion === 'number' || hello.minWireVersion instanceof Int32) &&
82+
hello.minWireVersion <= MAX_SUPPORTED_WIRE_VERSION;
8283

8384
if (serverVersionHighEnough) {
8485
if (serverVersionLowEnough) {
8586
return null;
8687
}
8788

8889
const message = `Server at ${options.hostAddress} reports minimum wire version ${JSON.stringify(
89-
ismaster.minWireVersion
90+
hello.minWireVersion
9091
)}, but this version of the Node.js Driver requires at most ${MAX_SUPPORTED_WIRE_VERSION} (MongoDB ${MAX_SUPPORTED_SERVER_VERSION})`;
9192
return new MongoCompatibilityError(message);
9293
}
9394

9495
const message = `Server at ${options.hostAddress} reports maximum wire version ${
95-
JSON.stringify(ismaster.maxWireVersion) ?? 0
96+
JSON.stringify(hello.maxWireVersion) ?? 0
9697
}, but this version of the Node.js Driver requires at least ${MIN_SUPPORTED_WIRE_VERSION} (MongoDB ${MIN_SUPPORTED_SERVER_VERSION})`;
9798
return new MongoCompatibilityError(message);
9899
}
@@ -146,9 +147,9 @@ function performInitialHandshake(
146147
return;
147148
}
148149

149-
if ('isWritablePrimary' in response) {
150-
// Provide pre-hello-style response document.
151-
response.ismaster = response.isWritablePrimary;
150+
if (!('isWritablePrimary' in response)) {
151+
// Provide hello-style response document.
152+
response.isWritablePrimary = response[LEGACY_HELLO_COMMAND];
152153
}
153154

154155
if (response.helloOk) {
@@ -179,8 +180,8 @@ function performInitialHandshake(
179180
// NOTE: This is metadata attached to the connection while porting away from
180181
// handshake being done in the `Server` class. Likely, it should be
181182
// relocated, or at very least restructured.
182-
conn.ismaster = response;
183-
conn.lastIsMasterMS = new Date().getTime() - start;
183+
conn.hello = response;
184+
conn.lastHelloMS = new Date().getTime() - start;
184185

185186
if (!response.arbiterOnly && credentials) {
186187
// store the response on auth context
@@ -209,6 +210,9 @@ function performInitialHandshake(
209210
}
210211

211212
export interface HandshakeDocument extends Document {
213+
/**
214+
* @deprecated Use hello instead
215+
*/
212216
ismaster?: boolean;
213217
hello?: boolean;
214218
helloOk?: boolean;
@@ -224,7 +228,7 @@ function prepareHandshakeDocument(authContext: AuthContext, callback: Callback<H
224228
const { serverApi } = authContext.connection;
225229

226230
const handshakeDoc: HandshakeDocument = {
227-
[serverApi?.version ? 'hello' : 'ismaster']: true,
231+
[serverApi?.version ? 'hello' : LEGACY_HELLO_COMMAND]: true,
228232
helloOk: true,
229233
client: options.metadata || makeClientMetadata(options),
230234
compression: compressors,

src/cmap/connection.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const kClusterTime = Symbol('clusterTime');
7070
/** @internal */
7171
const kDescription = Symbol('description');
7272
/** @internal */
73-
const kIsMaster = Symbol('ismaster');
73+
const kHello = Symbol('hello');
7474
/** @internal */
7575
const kAutoEncrypter = Symbol('autoEncrypter');
7676
/** @internal */
@@ -185,7 +185,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
185185
monitorCommands: boolean;
186186
closed: boolean;
187187
destroyed: boolean;
188-
lastIsMasterMS?: number;
188+
lastHelloMS?: number;
189189
serverApi?: ServerApi;
190190
helloOk?: boolean;
191191
/** @internal */
@@ -201,7 +201,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
201201
/** @internal */
202202
[kStream]: Stream;
203203
/** @internal */
204-
[kIsMaster]: Document;
204+
[kHello]: Document;
205205
/** @internal */
206206
[kClusterTime]: Document;
207207

@@ -240,7 +240,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
240240
this[kQueue] = new Map();
241241
this[kMessageStream] = new MessageStream({
242242
...options,
243-
maxBsonMessageSize: this.ismaster?.maxBsonMessageSize
243+
maxBsonMessageSize: this.hello?.maxBsonMessageSize
244244
});
245245
this[kMessageStream].on('message', messageHandler(this));
246246
this[kStream] = stream;
@@ -261,21 +261,21 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
261261
return this[kDescription];
262262
}
263263

264-
get ismaster(): Document {
265-
return this[kIsMaster];
264+
get hello(): Document {
265+
return this[kHello];
266266
}
267267

268-
// the `connect` method stores the result of the handshake ismaster on the connection
269-
set ismaster(response: Document) {
268+
// the `connect` method stores the result of the handshake hello on the connection
269+
set hello(response: Document) {
270270
this[kDescription].receiveResponse(response);
271271
this[kDescription] = Object.freeze(this[kDescription]);
272272

273273
// TODO: remove this, and only use the `StreamDescription` in the future
274-
this[kIsMaster] = response;
274+
this[kHello] = response;
275275
}
276276

277277
get serviceId(): ObjectId | undefined {
278-
return this.ismaster?.serviceId;
278+
return this.hello?.serviceId;
279279
}
280280

281281
get loadBalanced(): boolean {
@@ -321,7 +321,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
321321
if (issue.isTimeout) {
322322
op.cb(
323323
new MongoNetworkTimeoutError(`connection ${this.id} to ${this.address} timed out`, {
324-
beforeHandshake: this.ismaster == null
324+
beforeHandshake: this.hello == null
325325
})
326326
);
327327
} else if (issue.isClose) {

src/cmap/wire_protocol/compression.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as zlib from 'zlib';
22

3+
import { LEGACY_HELLO_COMMAND } from '../../constants';
34
import { PKG_VERSION, Snappy } from '../../deps';
45
import { MongoDecompressionError, MongoInvalidArgumentError } from '../../error';
56
import type { Callback } from '../../utils';
@@ -19,7 +20,7 @@ export type Compressor = typeof Compressor[CompressorName];
1920
export type CompressorName = keyof typeof Compressor;
2021

2122
export const uncompressibleCommands = new Set([
22-
'ismaster',
23+
LEGACY_HELLO_COMMAND,
2324
'saslStart',
2425
'saslContinue',
2526
'getnonce',

src/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,9 @@ export const MONGO_CLIENT_EVENTS = Object.freeze([
120120
* The legacy hello command that was deprecated in MongoDB 5.0.
121121
*/
122122
export const LEGACY_HELLO_COMMAND = 'ismaster';
123+
124+
/**
125+
* @internal
126+
* The legacy hello command that was deprecated in MongoDB 5.0.
127+
*/
128+
export const LEGACY_HELLO_COMMAND_CAMEL_CASE = 'isMaster';

src/operations/add_user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class AddUserOperation extends CommandOperation<Document> {
7575
roles = Array.isArray(options.roles) ? options.roles : [options.roles];
7676
}
7777

78-
const digestPassword = getTopology(db).lastIsMaster().maxWireVersion >= 7;
78+
const digestPassword = getTopology(db).lastHello().maxWireVersion >= 7;
7979

8080
let userPassword = password;
8181

src/sdam/events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export class TopologyClosedEvent {
123123
}
124124

125125
/**
126-
* Emitted when the server monitor’s ismaster command is started - immediately before
127-
* the ismaster command is serialized into raw BSON and written to the socket.
126+
* Emitted when the server monitor’s hello command is started - immediately before
127+
* the hello command is serialized into raw BSON and written to the socket.
128128
*
129129
* @public
130130
* @category Event
@@ -140,7 +140,7 @@ export class ServerHeartbeatStartedEvent {
140140
}
141141

142142
/**
143-
* Emitted when the server monitor’s ismaster succeeds.
143+
* Emitted when the server monitor’s hello succeeds.
144144
* @public
145145
* @category Event
146146
*/
@@ -161,7 +161,7 @@ export class ServerHeartbeatSucceededEvent {
161161
}
162162

163163
/**
164-
* Emitted when the server monitor’s ismaster fails, either with an “ok: 0” or a socket exception.
164+
* Emitted when the server monitor’s hello fails, either with an “ok: 0” or a socket exception.
165165
* @public
166166
* @category Event
167167
*/

0 commit comments

Comments
 (0)