Fix tests for fixed code, also fix another issue

This commit is contained in:
murgatroid99 2019-06-06 10:38:28 -07:00
parent 9aeca2f01a
commit 1ee218c8bd
2 changed files with 12 additions and 2 deletions

View File

@ -130,7 +130,16 @@ export class Http2CallStream extends Duplex implements Call {
private endCall(status: StatusObject): void {
if (this.finalStatus === null) {
this.finalStatus = status;
this.emit('status', status);
/* We do this asynchronously to ensure that no async function is in the
* call stack when we return control to the application. If an async
* function is in the call stack, any exception thrown by the application
* (or our tests) will bubble up and turn into promise rejection, which
* will result in an UnhandledPromiseRejectionWarning. Because that is
* a warning, the error will be effectively swallowed and execution will
* continue */
process.nextTick(() => {
this.emit('status', status);
});
}
}

View File

@ -196,7 +196,8 @@ describe('CallStream', () => {
reject(e);
}
});
http2Stream.emit('close', Number(key));
http2Stream.rstCode = Number(key);
http2Stream.emit('close');
});
});
});