Fix Desktop.Auth login key race under concurrent first access#77
Merged
Conversation
Concurrent first access from prepare_url and the Auth plug could mint different keys via non-atomic persistent_term check-then-set. Elect a single winner with ETS insert_new while keeping persistent_term as the fast read path. Co-authored-by: Cursor <[email protected]>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Drop the redundant ETS pre-lookup before insert_new, trim defensive test reset code, and keep persistent_term as the hot-path cache. Co-authored-by: Cursor <[email protected]>
Mirror the ddrive diagnostics: path, whether a k was present, and peer, so stale-key Unauthorized pages are visible in logs. Co-authored-by: Cursor <[email protected]>
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
Desktop.Auth.key/0: non-atomic:persistent_termcheck-then-set could mint two different keys whenWindow.prepare_url/1and the Auth plug initialize concurrently under load.?k=and a blank"Unauthorized"page (seen in diodechain/ddrive#4106).insert_new/2, keep:persistent_termas the fast read path, and keepset_key/1in sync with both stores.Test plan
NO_WX=1 mix test test/auth_test.exs test/window_test.exslogin_key/0callers always agree after a cold startMade with Cursor