grpc-js: use lazy singleton for server call deadline to avoid open handles in jest

This commit is contained in:
azban 2020-06-06 14:36:00 -07:00
parent 931a7c3e9e
commit e3a50ff3ee
1 changed files with 4 additions and 3 deletions

View File

@ -341,15 +341,13 @@ export type Handler<RequestType, ResponseType> =
export type HandlerType = 'bidi' | 'clientStream' | 'serverStream' | 'unary';
const noopTimer: NodeJS.Timer = setTimeout(() => {}, 0);
// Internal class that wraps the HTTP2 request.
export class Http2ServerCallStream<
RequestType,
ResponseType
> extends EventEmitter {
cancelled = false;
deadline: NodeJS.Timer = noopTimer;
deadline: NodeJS.Timer = setTimeout(() => {}, 0);
private wantTrailers = false;
private metadataSent = false;
private canPush = false;
@ -389,6 +387,9 @@ export class Http2ServerCallStream<
if ('grpc.max_receive_message_length' in options) {
this.maxReceiveMessageSize = options['grpc.max_receive_message_length']!;
}
// Clear noop timer
clearTimeout(this.deadline);
}
private checkCancelled(): boolean {