Skip to content

Commit

Permalink
Merge pull request #2536 from murgatroid99/grpc-js_pick_cancel_race
Browse files Browse the repository at this point in the history
grpc-js: Handle race between call cancellation and auth metadata generation
  • Loading branch information
murgatroid99 authored Aug 8, 2023
2 parents 99ae020 + 01749a8 commit 9ef4655
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/grpc-js/src/load-balancing-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ export class LoadBalancingCall implements Call {
.generateMetadata({ service_url: this.serviceUrl })
.then(
credsMetadata => {
/* If this call was cancelled (e.g. by the deadline) before
* metadata generation finished, we shouldn't do anything with
* it. */
if (this.ended) {
this.trace('Credentials metadata generation finished after call ended');
return;
}
const finalMetadata = this.metadata!.clone();
finalMetadata.merge(credsMetadata);
if (finalMetadata.get('authorization').length > 1) {
Expand Down

0 comments on commit 9ef4655

Please sign in to comment.