File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1240,11 +1240,14 @@ export function needsRetryableWriteLabel(
1240
1240
}
1241
1241
}
1242
1242
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 ) {
1244
1247
return RETRYABLE_WRITE_ERROR_CODES . has ( error . result ?. code ?? error . code ?? 0 ) ;
1245
1248
}
1246
1249
1247
- if ( error instanceof MongoError && typeof error . code === 'number' ) {
1250
+ if ( error instanceof MongoError && typeof error . code === 'number' && ! isShardedAndPre4_4 ) {
1248
1251
return RETRYABLE_WRITE_ERROR_CODES . has ( error . code ) ;
1249
1252
}
1250
1253
You can’t perform that action at this time.
0 commit comments