From d1af25266b85abb823c660086e9cae7adf3c718b Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sun, 22 Mar 2026 18:28:06 +0100 Subject: [PATCH] fix(pagespeed): increase fetch timeout for manual PSI checks to 120s PSI checks run mobile + desktop sequentially (up to 60s total). The default 30s client timeout was causing false network errors. --- lib/api/pagespeed.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/api/pagespeed.ts b/lib/api/pagespeed.ts index ede2fd7..c67f8a7 100644 --- a/lib/api/pagespeed.ts +++ b/lib/api/pagespeed.ts @@ -76,8 +76,16 @@ export async function getPageSpeedCheck(siteId: string, checkId: string): Promis } export async function triggerPageSpeedCheck(siteId: string): Promise { - const res = await apiRequest<{ checks: PageSpeedCheck[] }>(`/sites/${siteId}/pagespeed/check`, { - method: 'POST', - }) - return res?.checks ?? [] + // * PSI checks take 10-30s per strategy (mobile + desktop sequential = up to 60s) + const controller = new AbortController() + const timeoutId = setTimeout(() => controller.abort(), 120_000) + try { + const res = await apiRequest<{ checks: PageSpeedCheck[] }>(`/sites/${siteId}/pagespeed/check`, { + method: 'POST', + signal: controller.signal, + }) + return res?.checks ?? [] + } finally { + clearTimeout(timeoutId) + } }