Skip to content

Commit

Permalink
Merge pull request #2801 from hastom/master
Browse files Browse the repository at this point in the history
fix(grpc-js): client crash on custom error code
  • Loading branch information
murgatroid99 authored Jul 26, 2024
2 parents 43032b1 + 33073d0 commit f5ea6ce
Show file tree
Hide file tree
Showing 2 changed files with 17 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
16 changes: 16 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,22 @@ 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.code, 300);
assert.strictEqual(error.details, 'Failed on retry 0');
done();
}
);
});
});

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

0 comments on commit f5ea6ce

Please sign in to comment.