Skip to content

Commit

Permalink
Fix client crash on custom error code
Browse files Browse the repository at this point in the history
  • Loading branch information
hastom committed Jul 18, 2024
1 parent 7e4c8f0 commit 15d422d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/grpc-js/src/retrying-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class RetryingCall implements Call, DeadlineInfoProvider {
return list.some(
value =>
value === code ||
value.toString().toLowerCase() === Status[code].toLowerCase()
value.toString().toLowerCase() === Status[code]?.toLowerCase()
);
}

Expand Down
15 changes: 15 additions & 0 deletions packages/grpc-js/test/test-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ describe('Retries', () => {
}
);
});

it('Should not retry on custom error code', done => {
const metadata = new grpc.Metadata();
metadata.set('succeed-on-retry-attempt', '2');
metadata.set('respond-with-status', '300');
client.echo(
{ value: 'test value', value2: 3 },
metadata,
(error: grpc.ServiceError, response: any) => {
assert(error);
assert.strictEqual(error.details, 'Failed on retry 0');
done();
}
);
});
});

describe('Client with hedging configured', () => {
Expand Down

0 comments on commit 15d422d

Please sign in to comment.