Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Jul 29, 2024
1 parent a0bdcf4 commit 5f8020e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,6 @@ export class MongoWriteConcernError extends MongoServerError {
super({ ...result.writeConcernError, ...result });
this.errInfo = result.writeConcernError.errInfo;
this.result = result;
// original top-level code from server response
this.originalCode = result.code ?? undefined;
}

override get name(): string {
Expand Down Expand Up @@ -1253,12 +1251,13 @@ export function needsRetryableWriteLabel(
}

if (error instanceof MongoWriteConcernError) {
if (!(serverType === 'Mongos' && maxWireVersion < 9)) {
return RETRYABLE_WRITE_ERROR_CODES.has(
error.result.writeConcernError.code ?? Number(error.code) ?? 0
);
if (serverType === 'Mongos' && maxWireVersion < 9) {
// use original top-level code from server response
return RETRYABLE_WRITE_ERROR_CODES.has(error.result.code ?? 0);
}
return RETRYABLE_WRITE_ERROR_CODES.has(Number(error.originalCode) ?? 0);
return RETRYABLE_WRITE_ERROR_CODES.has(
error.result.writeConcernError.code ?? Number(error.code) ?? 0
);
}

if (error instanceof MongoError) {
Expand Down

0 comments on commit 5f8020e

Please sign in to comment.