From c6c031b11dd90b089c46fac8d9dc6450c267c36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Fri, 16 Feb 2024 10:38:00 +0100 Subject: [PATCH] fix: update the timeout logic --- src/hooks/browser-headers.ts | 4 ++-- src/hooks/http2.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/browser-headers.ts b/src/hooks/browser-headers.ts index e75af53..eb9140b 100644 --- a/src/hooks/browser-headers.ts +++ b/src/hooks/browser-headers.ts @@ -39,12 +39,12 @@ const getResolveProtocolFunction = (options: Options, proxyUrl: string | undefin } if (proxyUrl) { - return createResolveProtocol(proxyUrl, sessionData as any, options?.timeout?.connect ?? options?.timeout?.request); + return createResolveProtocol(proxyUrl, sessionData as any, Math.min(options?.timeout?.connect ?? 60_000, options?.timeout?.request ?? 60_000)); } return (...args: Parameters) => http2.auto.resolveProtocol({ ...args[0], - timeout: options?.timeout?.connect ?? options?.timeout?.request, + timeout: Math.min(options?.timeout?.connect ?? 60_000, options?.timeout?.request ?? 60_000), }); }; diff --git a/src/hooks/http2.ts b/src/hooks/http2.ts index 2231350..c0037da 100644 --- a/src/hooks/http2.ts +++ b/src/hooks/http2.ts @@ -14,7 +14,7 @@ export function http2Hook(options: Options): void { typedRequestOptions.resolveProtocol = createResolveProtocol( proxyUrl, sessionData as any, - options?.timeout?.connect ?? options?.timeout?.request, + Math.min(options?.timeout?.connect ?? 60_000, options?.timeout?.request ?? 60_000), ); }