Merge pull request #2536 from murgatroid99/grpc-js_pick_cancel_race

grpc-js: Handle race between call cancellation and auth metadata generation
This commit is contained in:
Michael Lumish 2023-08-08 15:01:00 -07:00 committed by GitHub
commit 9ef4655b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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) {