From 74d3718d52e6fc0fb4716aa7a2392429104b7662 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 25 Mar 2022 13:31:49 -0400 Subject: [PATCH] cannot use refresh on cleared timer --- src/cmap/connection.ts | 11 ++++------- test/tools/utils.ts | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index d8dcf853b2b..88d21da099c 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -258,13 +258,9 @@ export class Connection extends TypedEventEmitter { stream.on('close', () => this.handleIssue({ isClose: true })); stream.on('timeout', () => { - if (this.delayedTimeoutErrorId != null) { - this.delayedTimeoutErrorId.refresh(); - } else { - this.delayedTimeoutErrorId = setTimeout(() => { - this.handleIssue({ isTimeout: true, destroy: true }); - }, 1); - } + this.delayedTimeoutErrorId = setTimeout(() => { + this.handleIssue({ isTimeout: true, destroy: true }); + }, 1); }); // hook the message stream up to the passed in stream @@ -722,6 +718,7 @@ function messageHandler(conn: Connection) { return function messageHandler(message: BinMsg | Response) { if (conn.delayedTimeoutErrorId != null) { clearTimeout(conn.delayedTimeoutErrorId); + conn.delayedTimeoutErrorId = null; } // always emit the message, in case we are streaming diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 9ee635e6de4..1fb6ed6ce77 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -13,7 +13,6 @@ export function makeTestFunction(config: DeprecateOptionsConfig) { } export function ensureCalledWith(stub: any, args: any[]) { - // @ts-expect-error: sinonChai plugin args.forEach((m: any) => expect(stub).to.have.been.calledWith(m)); } @@ -33,7 +32,7 @@ ClassWithLogger.prototype.getLogger = function () { }; // creation of class without a logger -function ClassWithoutLogger() { +export function ClassWithoutLogger() { // empty function for class } @@ -44,7 +43,7 @@ ClassWithoutLogger.prototype.f = makeTestFunction({ }); // creation of class where getLogger returns undefined -function ClassWithUndefinedLogger() { +export function ClassWithUndefinedLogger() { // empty function for class }