Skip to content

Commit ad5b150

Browse files
remove stray only
clear up logic lint fix clean up lint fix 2
1 parent 440bac7 commit ad5b150

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/cmap/connect.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
MIN_SUPPORTED_SERVER_VERSION,
3232
MIN_SUPPORTED_WIRE_VERSION
3333
} from './wire_protocol/constants';
34-
import { isSharded } from './wire_protocol/shared';
3534

3635
/** @public */
3736
export type Stream = Socket | TLSSocket;
@@ -165,7 +164,7 @@ export async function performInitialHandshake(
165164
} catch (error) {
166165
if (error instanceof MongoError) {
167166
error.addErrorLabel(MongoErrorLabel.HandshakeError);
168-
if (needsRetryableWriteLabel(error, response.maxWireVersion, isSharded(conn))) {
167+
if (needsRetryableWriteLabel(error, response.maxWireVersion, conn.description.type)) {
169168
error.addErrorLabel(MongoErrorLabel.RetryableWriteError);
170169
}
171170
}

src/error.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Document } from './bson';
2+
import type { ServerType } from './sdam/common';
23
import type { TopologyVersion } from './sdam/server_description';
34
import type { TopologyDescription } from './sdam/topology_description';
45

@@ -1220,7 +1221,7 @@ const RETRYABLE_WRITE_ERROR_CODES = RETRYABLE_READ_ERROR_CODES;
12201221
export function needsRetryableWriteLabel(
12211222
error: Error,
12221223
maxWireVersion: number,
1223-
isSharded: boolean
1224+
serverType: ServerType
12241225
): boolean {
12251226
// pre-4.4 server, then the driver adds an error label for every valid case
12261227
// execute operation will only inspect the label, code/message logic is handled here
@@ -1241,13 +1242,13 @@ export function needsRetryableWriteLabel(
12411242
}
12421243

12431244
if (error instanceof MongoWriteConcernError) {
1244-
return isSharded && maxWireVersion < 9
1245+
return serverType === 'Mongos' && maxWireVersion < 9
12451246
? false
1246-
: RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0);
1247+
: RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? Number(error.code) ?? 0);
12471248
}
12481249

12491250
if (error instanceof MongoError && typeof error.code === 'number') {
1250-
return RETRYABLE_WRITE_ERROR_CODES.has(error.code);
1251+
return RETRYABLE_WRITE_ERROR_CODES.has(Number(error.code));
12511252
}
12521253

12531254
const isNotWritablePrimaryError = LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(error.message);

src/sdam/server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from '../cmap/connection_pool';
99
import { PoolClearedError } from '../cmap/errors';
1010
import { type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses';
11-
import { isSharded } from '../cmap/wire_protocol/shared';
1211
import {
1312
APM_EVENTS,
1413
CLOSED,
@@ -454,7 +453,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
454453
} else {
455454
if (
456455
(isRetryableWritesEnabled(this.topology) || isTransactionCommand(cmd)) &&
457-
needsRetryableWriteLabel(error, maxWireVersion(this), isSharded(this)) &&
456+
needsRetryableWriteLabel(error, maxWireVersion(this), this.description.type) &&
458457
!inActiveTransaction(session, cmd)
459458
) {
460459
error.addErrorLabel(MongoErrorLabel.RetryableWriteError);

test/integration/retryable-writes/retryable_writes.spec.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface RetryableWriteTestContext {
1515
failPointName?: any;
1616
}
1717

18-
describe.only('Legacy Retryable Writes Specs', function () {
18+
describe('Legacy Retryable Writes Specs', function () {
1919
let ctx: RetryableWriteTestContext = {};
2020

2121
const retryableWrites = loadSpecTests('retryable-writes', 'legacy');
@@ -229,6 +229,6 @@ async function turnOffFailPoint(client, name) {
229229
});
230230
}
231231

232-
describe.only('Retryable Writes (unified)', function () {
232+
describe('Retryable Writes (unified)', function () {
233233
runUnifiedSuite(loadSpecTests(path.join('retryable-writes', 'unified')));
234234
});

0 commit comments

Comments
 (0)