Skip to content

Commit 1ee218c

Browse files
committed
Fix tests for fixed code, also fix another issue
1 parent 9aeca2f commit 1ee218c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/grpc-js/src/call-stream.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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

packages/grpc-js/test/test-call-stream.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)