Skip to content

Fix OAuth account connection hanging with "Background script not responding"#27

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-connecting-account-fails
Draft

Fix OAuth account connection hanging with "Background script not responding"#27
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-connecting-account-fails

Conversation

Copy link
Copy Markdown

Copilot AI commented May 3, 2026

After completing the Google OAuth flow, the extension would hang for ~30 seconds before showing "Background script not responding" — instead of connecting the account. The background service worker was silently returning in failure cases without notifying the options page, leaving it waiting indefinitely.

Changes

  • Missing early return on isWorking guard — error was sent but execution fell through and launched a second concurrent auth flow; added return to exit cleanly.

  • Silent returns replaced with explicit errors — two cases where the background returned without messaging the options page:

    • launchWebAuthFlow resolving to undefined (cancelled, blocked, or popup closed mid-flow)
    • Token extraction failure
  • Fragile regex → URLSearchParams — old regex /\#(?:access_token)\=([\S\s]*?)\&/ required a trailing &, silently breaking if access_token is the last fragment parameter (parameter ordering is not guaranteed by Google):

// Before — breaks if access_token is last in fragment
const tokenMatch = redirectTokenUrl.match(/\#(?:access_token)\=([\S\s]*?)\&/);
const token = tokenMatch[1];

// After — order-independent, standards-compliant
const redirectUrl = new URL(redirectTokenUrl);
const hashParams = new URLSearchParams(redirectUrl.hash.substring(1));
const token = hashParams.get("access_token");

Copilot AI linked an issue May 3, 2026 that may be closed by this pull request
… for token extraction, send errors on failure

Agent-Logs-Url: https://github.com/biplobsd/yst/sessions/c6a810d9-4a0c-4c8e-9c6c-98c1674bc7f7

Co-authored-by: biplobsd <43641536+biplobsd@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix connecting account issue with Google authentication Fix OAuth account connection hanging with "Background script not responding" May 3, 2026
Copilot AI requested a review from biplobsd May 3, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connecting account fails

2 participants