Skip to content

Commit 9ef4655

Browse files
authored
Merge pull request #2536 from murgatroid99/grpc-js_pick_cancel_race
grpc-js: Handle race between call cancellation and auth metadata generation
2 parents 99ae020 + 01749a8 commit 9ef4655

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ 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+
this.trace('Credentials metadata generation finished after call ended');
148+
return;
149+
}
143150
const finalMetadata = this.metadata!.clone();
144151
finalMetadata.merge(credsMetadata);
145152
if (finalMetadata.get('authorization').length > 1) {

0 commit comments

Comments
 (0)