Merge pull request #1273 from murgatroid99/grpc-js_pick_error_handling

Clone metadata going into the metadata filter stack
This commit is contained in:
Michael Lumish 2020-02-24 12:39:02 -08:00 committed by GitHub
commit 7a4c52b572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "0.6.17",
"version": "0.6.18",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -250,8 +250,11 @@ export class ChannelImplementation implements Channel {
this.pickQueue.push({ callStream, callMetadata });
break;
}
/* We need to clone the callMetadata here because the transparent
* retry code in the promise resolution handler use the same
* callMetadata object, so it needs to stay unmodified */
callStream.filterStack
.sendMetadata(Promise.resolve(callMetadata))
.sendMetadata(Promise.resolve(callMetadata.clone()))
.then(
finalMetadata => {
const subchannelState: ConnectivityState = pickResult.subchannel!.getConnectivityState();
@ -280,6 +283,8 @@ export class ChannelImplementation implements Channel {
'channel',
'Failed to start call on picked subchannel ' +
pickResult.subchannel!.getAddress() +
' with error ' +
(error as Error).message +
'. Retrying pick'
);
this.tryPick(callStream, callMetadata);