Merge branch 'main' into main

This commit is contained in:
shijun 2025-04-05 11:36:43 +08:00 • committed by GitHub
commit 9482d936d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,6 +108,7 @@ type TimeoutInfo = {
startTime: number;
timeout: number;
maxTotalTimeout?: number;
resetTimeoutOnProgress: boolean;
onTimeout: () => void;
};
@ -189,13 +190,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
});
}
@ -375,7 +378,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) {
@ -537,7 +542,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);