Skip to content

Fix token exchange race condition and relative URL#566

Open
phoenixy1 wants to merge 1 commit intomasterfrom
ah-quickstart-bug-fixes
Open

Fix token exchange race condition and relative URL#566
phoenixy1 wants to merge 1 commit intomasterfrom
ah-quickstart-bug-fixes

Conversation

@phoenixy1
Copy link
Copy Markdown
Collaborator

@phoenixy1 phoenixy1 commented Apr 16, 2026

Summary

  • Await token exchange before navigating: onSuccess was calling exchangePublicTokenForAccessToken() without awaiting it, then immediately dispatching linkSuccess: true. On slow connections or backend errors, the UI would show the success view before the access token was available, causing all subsequent API calls to fail.
  • Fix relative URL: fetch("api/create_user_token") was missing its leading slash. All other fetch calls use /api/....

Test plan

  • Complete a Link flow and verify the success view shows the correct access_token and item_id
  • Simulate a slow backend on /api/set_access_token and verify the UI doesn't navigate prematurely

🤖 Generated with Claude Code

Claude Session: bd5bab3d-1669-47a1-bd2e-3fa4a399eb6b

Await exchangePublicTokenForAccessToken() before dispatching
linkSuccess so the UI doesn't navigate to the success view before the
access_token is available. Previously, slow or failed exchanges would
leave the app in a broken state where API calls fail silently.

Also fix a relative URL in the create_user_token fetch call that would
resolve incorrectly if the app were loaded at a non-root path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@phoenixy1 phoenixy1 requested a review from reverentgeek April 17, 2026 21:53
@phoenixy1 phoenixy1 marked this pull request as ready for review April 17, 2026 21:53
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.

1 participant