From 24c2f7c2fcf672d027afb4e238a2eed8d89f8c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20De=20Freitas?= <6485562+adefreitas@users.noreply.github.com> Date: Thu, 16 Apr 2026 16:02:32 +0100 Subject: [PATCH] fix(ENG-12551): fix COOP detection race condition and empty response parsing COOP detection at popup open time is unreliable because the browser hasn't enforced the policy yet (popup starts at about:blank). When COOP kicks in later, the popup watcher incorrectly treats it as user-closed and cancels the connection attempt. Fix by deferring to polling whenever it is active, regardless of COOP detection. Also fix DELETE response parsing crash (empty body) and reduce cancel button delay from 8s to 5s. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/modules/integration-picker/hooks/useIntegrationPicker.ts | 2 +- src/shared/components/loading.tsx | 2 +- src/shared/httpClient.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/integration-picker/hooks/useIntegrationPicker.ts b/src/modules/integration-picker/hooks/useIntegrationPicker.ts index 0796a0a..f4836fd 100644 --- a/src/modules/integration-picker/hooks/useIntegrationPicker.ts +++ b/src/modules/integration-picker/hooks/useIntegrationPicker.ts @@ -603,7 +603,7 @@ export const useIntegrationPicker = ({ window.removeEventListener('message', processMessageCallback, false); - if (coopDetectedRef.current && pollingIntervalRef.current) return; + if (pollingIntervalRef.current) return; const connectionAttemptId = connectionAttemptIdRef.current; teardownOAuth(); diff --git a/src/shared/components/loading.tsx b/src/shared/components/loading.tsx index 512419f..6db4827 100644 --- a/src/shared/components/loading.tsx +++ b/src/shared/components/loading.tsx @@ -19,7 +19,7 @@ export const Loading: React.FC<{ useEffect(() => { if (!onCancel) return; - timerRef.current = setTimeout(() => setShowCancel(true), 8000); + timerRef.current = setTimeout(() => setShowCancel(true), 5000); return () => { if (timerRef.current) clearTimeout(timerRef.current); }; diff --git a/src/shared/httpClient.ts b/src/shared/httpClient.ts index 0c9ee3e..7b83220 100644 --- a/src/shared/httpClient.ts +++ b/src/shared/httpClient.ts @@ -54,7 +54,9 @@ export async function request({ } } - return (await response.json()) as T; + const text = await response.text(); + if (!text) return null; + return JSON.parse(text) as T; } } catch (error) { logger.error(`Error making request to ${url}`, error);