From 92da5861f4fded8f21315cb18dbe620535214000 Mon Sep 17 00:00:00 2001 From: Tuomas Date: Tue, 25 Feb 2025 11:30:50 -0600 Subject: [PATCH] Fix resetTimeoutOnProgress option not being checked --- src/shared/protocol.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shared/protocol.ts b/src/shared/protocol.ts index 97213bf0..ccfcdbc1 100644 --- a/src/shared/protocol.ts +++ b/src/shared/protocol.ts @@ -98,6 +98,7 @@ type TimeoutInfo = { startTime: number; timeout: number; maxTotalTimeout?: number; + resetTimeoutOnProgress: boolean; onTimeout: () => void; }; @@ -179,13 +180,15 @@ export abstract class Protocol< messageId: number, timeout: number, maxTotalTimeout: number | undefined, - onTimeout: () => void + onTimeout: () => void, + resetTimeoutOnProgress: boolean = false ) { this._timeoutInfo.set(messageId, { timeoutId: setTimeout(onTimeout, timeout), startTime: Date.now(), timeout, maxTotalTimeout, + resetTimeoutOnProgress, onTimeout }); } @@ -358,7 +361,9 @@ export abstract class Protocol< } const responseHandler = this._responseHandlers.get(messageId); - if (this._timeoutInfo.has(messageId) && responseHandler) { + const timeoutInfo = this._timeoutInfo.get(messageId); + + if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) { try { this._resetTimeout(messageId); } catch (error) { @@ -520,7 +525,7 @@ export abstract class Protocol< { timeout } )); - this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler); + this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false); this._transport.send(jsonrpcRequest).catch((error) => { this._cleanupTimeout(messageId);