Skip to content

Commit 30bc44f

Browse files
committed
grpc-js: Handle race between call cancellation and auth metadata generation
1 parent f6dd4aa commit 30bc44f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/grpc-js/src/load-balancing-call.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export class LoadBalancingCall implements Call {
140140
.generateMetadata({ service_url: this.serviceUrl })
141141
.then(
142142
credsMetadata => {
143+
/* If this call was cancelled (e.g. by the deadline) before
144+
* metadata generation finished, we shouldn't do anything with
145+
* it. */
146+
if (this.ended) {
147+
return;
148+
}
143149
const finalMetadata = this.metadata!.clone();
144150
finalMetadata.merge(credsMetadata);
145151
if (finalMetadata.get('authorization').length > 1) {

0 commit comments

Comments
 (0)