Repository navigation
web/flow: Continuous Login Locks - #25692
GirlBossRush wants to merge 5 commits into
Conversation
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25692 +/- ##
==========================================
- Coverage 92.42% 92.39% -0.04%
==========================================
Files 1192 1192
Lines 80539 80539
Branches 4351 4351
==========================================
- Hits 74437 74411 -26
- Misses 6036 6062 +26
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Playwright e2e — ❌ Failed
Workflow run · HTML report hosting is gated off until the |
3410d7c to
36706db
Compare
36706db to
7af462e
Compare
fcaf365 to
c73a0cb
Compare
0b5bf96 to
6a68e4b
Compare
Playwright e2eDownload this run's HTML report and traces, then open the report: gh run download 40516635235 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-report |
Replace the hand-rolled localStorage lock — a non-atomic check-then-set guarded by a tab-liveness heuristic — with navigator.locks. `ifAvailable` gives immediate leader election with no double-leader race, and the browser releases the lock on navigation or close, so there is no stale lock to reap and no manual cleanup.
Drive two real tabs in one browser context: authenticate in the leader and assert the follower leaves the identification stage on its own. The global flag is enabled in beforeAll and restored in afterAll; the file carries the highest numeric prefix and runs serially so it does not race the parallel login suite.
Move the global-flag toggle into an e2e/ helper (setInstanceFlag) so the test stops hand-constructing fixtures inline, and confirm the settings save through its success toast instead of matching the settings network response — keeping the flow on the UI like the rest of the suite.
6a68e4b to
05eac54
Compare
|
Resolved in #26269 |
Details
This PR replaces the hand-rolled
localStorageleader-election lock in the continuous-login tab orchestrator with the Web Locks API.The previous localStorage approach is fairly consistent, but a few race-conditions given the right setup. Two tabs authenticating near-simultaneously could let both win the leadership role, letting them both attempt to drive the resume. The storage key could also become stale and needed a tab-liveness check (
tabs.has(lockTabID)).Now, calling
navigator.locks.request(lockKey, { ifAvailable: true }, …)gives a single leader election, and the browser releases the lock automatically on navigation or tab close — removing both the race and the liveness heuristic.Testing
Adds a Playwright e2e test (
web/test/browser/999-continuous-login.test.ts) that drives two real tabs and asserts the follower resumes once the leader authenticates. The two tabs open on the identification stage, the leader authenticates, and the follower reaches/if/user/on its own without credentials being entered in it.