Skip to content

Commit 1599a1c

Browse files
committed
don't recreate timeout
1 parent 9563b76 commit 1599a1c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/cmap/connection.ts

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

260260
stream.on('timeout', () => {
261-
this.delayedTimeoutErrorId = setTimeout(() => {
262-
this.handleIssue({ isTimeout: true, destroy: true });
263-
}, 1);
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+
}
264268
});
265269

266270
// hook the message stream up to the passed in stream
@@ -718,7 +722,6 @@ function messageHandler(conn: Connection) {
718722
return function messageHandler(message: BinMsg | Response) {
719723
if (conn.delayedTimeoutErrorId != null) {
720724
clearTimeout(conn.delayedTimeoutErrorId);
721-
conn.delayedTimeoutErrorId = null;
722725
}
723726

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

0 commit comments

Comments
 (0)