Skip to content

Commit 74d3718

Browse files
committed
cannot use refresh on cleared timer
1 parent 1599a1c commit 74d3718

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/cmap/connection.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,9 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
258258
stream.on('close', () => this.handleIssue({ isClose: true }));
259259

260260
stream.on('timeout', () => {
261-
if (this.delayedTimeoutErrorId != null) {
262-
this.delayedTimeoutErrorId.refresh();
263-
} else {
264-
this.delayedTimeoutErrorId = setTimeout(() => {
265-
this.handleIssue({ isTimeout: true, destroy: true });
266-
}, 1);
267-
}
261+
this.delayedTimeoutErrorId = setTimeout(() => {
262+
this.handleIssue({ isTimeout: true, destroy: true });
263+
}, 1);
268264
});
269265

270266
// hook the message stream up to the passed in stream
@@ -722,6 +718,7 @@ function messageHandler(conn: Connection) {
722718
return function messageHandler(message: BinMsg | Response) {
723719
if (conn.delayedTimeoutErrorId != null) {
724720
clearTimeout(conn.delayedTimeoutErrorId);
721+
conn.delayedTimeoutErrorId = null;
725722
}
726723

727724
// always emit the message, in case we are streaming

test/tools/utils.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function makeTestFunction(config: DeprecateOptionsConfig) {
1313
}
1414

1515
export function ensureCalledWith(stub: any, args: any[]) {
16-
// @ts-expect-error: sinonChai plugin
1716
args.forEach((m: any) => expect(stub).to.have.been.calledWith(m));
1817
}
1918

@@ -33,7 +32,7 @@ ClassWithLogger.prototype.getLogger = function () {
3332
};
3433

3534
// creation of class without a logger
36-
function ClassWithoutLogger() {
35+
export function ClassWithoutLogger() {
3736
// empty function for class
3837
}
3938

@@ -44,7 +43,7 @@ ClassWithoutLogger.prototype.f = makeTestFunction({
4443
});
4544

4645
// creation of class where getLogger returns undefined
47-
function ClassWithUndefinedLogger() {
46+
export function ClassWithUndefinedLogger() {
4847
// empty function for class
4948
}
5049

0 commit comments

Comments
 (0)