grpc-js: Handle race between call cancellation and auth metadata generation

This commit is contained in:
Michael Lumish 2023-08-02 16:48:57 -07:00
parent f6dd4aad55
commit 30bc44f4ce
1 changed files with 6 additions and 0 deletions

View File

@ -140,6 +140,12 @@ 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) {
return;
}
const finalMetadata = this.metadata!.clone();
finalMetadata.merge(credsMetadata);
if (finalMetadata.get('authorization').length > 1) {