Skip to content

Commit 729d992

Browse files
pls pass tests
1 parent 580ee4e commit 729d992

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/error.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,11 +1240,14 @@ export function needsRetryableWriteLabel(
12401240
}
12411241
}
12421242

1243-
if (error instanceof MongoWriteConcernError && !isSharded && maxWireVersion >= 9) {
1243+
// For writeErrors and writeConcernErrors from a pre-4.4 mongos response, do not use the code to determine retryability.
1244+
const isShardedAndPre4_4 = !isSharded && maxWireVersion >= 9;
1245+
1246+
if (error instanceof MongoWriteConcernError && !isShardedAndPre4_4) {
12441247
return RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0);
12451248
}
12461249

1247-
if (error instanceof MongoError && typeof error.code === 'number') {
1250+
if (error instanceof MongoError && typeof error.code === 'number' && !isShardedAndPre4_4) {
12481251
return RETRYABLE_WRITE_ERROR_CODES.has(error.code);
12491252
}
12501253

0 commit comments

Comments
 (0)