From 205f237928174154f247228796784dd3ab6ad532 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 14 Mar 2018 14:01:11 -0700 Subject: [PATCH] Don't handle already-finished call in channel --- packages/grpc-js-core/src/channel.ts | 26 ++++++++++++-------------- test/any_grpc.js | 1 - 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/grpc-js-core/src/channel.ts b/packages/grpc-js-core/src/channel.ts index 22a9c586..a4d04023 100644 --- a/packages/grpc-js-core/src/channel.ts +++ b/packages/grpc-js-core/src/channel.ts @@ -239,20 +239,18 @@ export class Http2Channel extends EventEmitter implements Channel { headers[HTTP2_HEADER_METHOD] = 'POST'; headers[HTTP2_HEADER_PATH] = methodName; headers[HTTP2_HEADER_TE] = 'trailers'; - if (stream.getStatus() === null) { - if (this.connectivityState === ConnectivityState.READY) { - const session: http2.ClientHttp2Session = this.subChannel!; - // Prevent the HTTP/2 session from keeping the process alive. - // Note: this function is only available in Node 9 - session.unref(); - stream.attachHttp2Stream(session.request(headers)); - } else { - /* In this case, we lost the connection while finalizing - * metadata. That should be very unusual */ - setImmediate(() => { - this.startHttp2Stream(methodName, stream, metadata); - }); - } + if (this.connectivityState === ConnectivityState.READY) { + const session: http2.ClientHttp2Session = this.subChannel!; + // Prevent the HTTP/2 session from keeping the process alive. + // Note: this function is only available in Node 9 + session.unref(); + stream.attachHttp2Stream(session.request(headers)); + } else { + /* In this case, we lost the connection while finalizing + * metadata. That should be very unusual */ + setImmediate(() => { + this.startHttp2Stream(methodName, stream, metadata); + }); } }).catch((error: Error & { code: number }) => { // We assume the error code isn't 0 (Status.OK) diff --git a/test/any_grpc.js b/test/any_grpc.js index a434d41b..250f0098 100644 --- a/test/any_grpc.js +++ b/test/any_grpc.js @@ -11,7 +11,6 @@ function getImplementation(globalField) { 'If running from the command line, please --require a fixture first.' ].join(' ')); } - console.error(globalField, global[globalField]); const impl = global[globalField]; return require(`../packages/grpc-${impl}-core`); }