Merge pull request #221 from murgatroid99/interop_cancel_fixes

Don't handle already-finished call in channel
This commit is contained in:
Michael Lumish 2018-03-14 14:59:54 -07:00 committed by GitHub
commit aeb8175cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -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)

View File

@ -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`);
}