File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,16 @@ export class Http2CallStream extends Duplex implements Call {
130130 private endCall ( status : StatusObject ) : void {
131131 if ( this . finalStatus === null ) {
132132 this . finalStatus = status ;
133- this . emit ( 'status' , status ) ;
133+ /* We do this asynchronously to ensure that no async function is in the
134+ * call stack when we return control to the application. If an async
135+ * function is in the call stack, any exception thrown by the application
136+ * (or our tests) will bubble up and turn into promise rejection, which
137+ * will result in an UnhandledPromiseRejectionWarning. Because that is
138+ * a warning, the error will be effectively swallowed and execution will
139+ * continue */
140+ process . nextTick ( ( ) => {
141+ this . emit ( 'status' , status ) ;
142+ } ) ;
134143 }
135144 }
136145
Original file line number Diff line number Diff line change @@ -196,7 +196,8 @@ describe('CallStream', () => {
196196 reject ( e ) ;
197197 }
198198 } ) ;
199- http2Stream . emit ( 'close' , Number ( key ) ) ;
199+ http2Stream . rstCode = Number ( key ) ;
200+ http2Stream . emit ( 'close' ) ;
200201 } ) ;
201202 } ) ;
202203 } ) ;
You can’t perform that action at this time.
0 commit comments