Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/modules/integration-picker/hooks/useIntegrationPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,13 @@ export const useIntegrationPicker = ({
if (coopDetectedRef.current) return;

const attemptId = connectionAttemptIdRef.current;
if (!attemptId) {
closeOAuthPopup();
setConnectionState({ loading: false, success: false });
return;
}
if (!attemptId) return;

// A cross-origin popup under COOP reports `closed === true` once it navigates to the
// provider, even while the user is still authenticating — indistinguishable from a
// genuine user-close. So never cancel a still-pending attempt here; defer to the poll
// loop (authenticated / error / cancelled / expired / timeout), as the first-tick COOP
// path already does. Genuine closes resolve via the poll timeout or the Cancel button.
const final = await pollConnectionAttempt(baseUrl, token, attemptId).catch(
(error) => {
if (debugRef.current) {
Expand Down Expand Up @@ -497,18 +498,11 @@ export const useIntegrationPicker = ({
}

if (debugRef.current) {
console.debug('[hub] popup closed by user, cancelling attempt', { attemptId });
console.debug(
'[hub] popup reported closed but attempt still pending — deferring to poll loop (likely cross-origin/COOP false-close)',
{ attemptId },
);
}
closeOAuthPopup();
cancelConnectionAttempt(baseUrl, token, attemptId).catch((error) => {
if (debugRef.current) {
console.debug('[hub] cancelConnectionAttempt failed', {
attemptId,
error,
});
}
});
setConnectionState({ loading: false, success: false });
};
popupWatcherRef.current = window.setTimeout(check, 1000);
},
Expand Down
Loading