fix(ENG-12551): fix COOP detection race condition and empty response parsing#135
Merged
adefreitas merged 1 commit intoApr 16, 2026
Conversation
…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) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the OAuth “connect account” flow reliability by preventing false “popup closed” handling when COOP is enforced, hardens the shared HTTP client against empty DELETE responses, and shortens the time before users can cancel a stalled connection attempt.
Changes:
- Adjust OAuth popup watcher logic to defer “popup closed” handling when polling is active (COOP race mitigation).
- Update
httpClientresponse parsing to tolerate empty response bodies by parsing text conditionally. - Reduce the cancel affordance delay in the loading UI from 8s to 5s.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/shared/httpClient.ts |
Changes response parsing to avoid response.json() throwing on empty bodies. |
src/shared/components/loading.tsx |
Speeds up showing the “Cancel and start over” action. |
src/modules/integration-picker/hooks/useIntegrationPicker.ts |
Prevents popup watcher from cancelling/resetting while polling is active (COOP mitigation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| return (await response.json()) as T; | ||
| const text = await response.text(); | ||
| if (!text) return null; |
| window.removeEventListener('message', processMessageCallback, false); | ||
|
|
||
| if (coopDetectedRef.current && pollingIntervalRef.current) return; | ||
| if (pollingIntervalRef.current) return; |
Comment on lines
+57
to
60
| const text = await response.text(); | ||
| if (!text) return null; | ||
| return JSON.parse(text) as T; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
about:blankbefore enforcing the policy, soconnectWindow.closedreadsfalseinitially. When COOP kicks in later, the popup watcher incorrectly interprets it as user-closed and cancels the connection attempt, resetting back to edit mode. Fixed by deferring to polling whenever it is active, regardless of COOP detection./connection_attempts/:idreturns an empty body, causingresponse.json()to throw. Now reads as text first and only parses if non-empty.Test plan
🤖 Generated with Claude Code
Summary by cubic
Fixes OAuth popup COOP race by always using polling when active, preventing early cancellation. Also handles empty HTTP responses and shows the cancel button sooner. Supports ENG-12551 by keeping the hub in loading while server-side polling completes under COOP.
request<T>(), readresponse.text()and JSON-parse only if non-empty to avoid crashes on empty DELETE responses.Written for commit 24c2f7c. Summary will update on new commits.