Fix token exchange race condition and relative URL#566
Open
Fix token exchange race condition and relative URL#566
Conversation
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>
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
onSuccesswas callingexchangePublicTokenForAccessToken()without awaiting it, then immediately dispatchinglinkSuccess: 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.fetch("api/create_user_token")was missing its leading slash. All other fetch calls use/api/....Test plan
access_tokenanditem_id/api/set_access_tokenand verify the UI doesn't navigate prematurely🤖 Generated with Claude Code
Claude Session: bd5bab3d-1669-47a1-bd2e-3fa4a399eb6b