Fix authentication request mismatch: double-tap guard + stale redirect drop - #9
Merged
Merged
Conversation
Two real triggers for "authentication request mismatch", both now fixed: - Continue had no debounce: two rapid taps could fire authenticate() twice before the first tap's state change recomposed the button away, so the second call's POST /authentication overwrote the pending request the first call's Custom Tab was about to redirect back to. LoginScreen now disables Continue synchronously on click via a local guard, independent of the coroutine's state update. - Tapping "Try again" while an earlier Custom Tab is still alive is a legitimate, intentional way to restart — but that old tab can still redirect back afterwards with its now-superseded authenticationRequestId. authenticate() already logged this abandonment; completeAuthenticationRequest() now checks the redirect's ID against it and drops a recognized stale redirect quietly (info log, no _authStatus change, no user-facing error) instead of throwing "Authentication request mismatch". An unrecognized mismatch still throws — that's still a genuine problem worth surfacing.
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
Follow-up to #8 (merged) — the diagnostic logging it added surfaced a real "authentication request mismatch" happening in practice, root-caused here.
Two distinct triggers, both fixed:
onClick, so two rapid taps could fireauthenticate()twice before the first tap's status update recomposed the button away. The second call'sPOST /authenticationoverwrites the pending request the first call's Custom Tab is about to redirect back to → mismatch.LoginScreennow disables Continue synchronously on click via a local guard (signInStarting), independent of the coroutine's async state update, so a second tap in the same frame is a no-op.authenticationRequestId.authenticate()already logged this abandonment;completeAuthenticationRequest()now checks the redirect's ID against the recorded abandoned one and drops a recognized stale redirect quietly (info log, no_authStatusmutation, no user-facing error) instead of throwingAuthressException("Authentication request mismatch"). A mismatch that isn't a recognized abandonment still throws — that's still a real problem worth surfacing.Test plan
Generated by Claude Code