♻️ replace custom cookie lock with native Web Locks API#4294
♻️ replace custom cookie lock with native Web Locks API#4294thomas-lebeau wants to merge 3 commits intov7from
Conversation
ffe2ea5 to
8a8065a
Compare
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
8a8065a to
cd03262
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 2ee6b36 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
a94a0dd to
bd49ace
Compare
- Remove sessionStoreOperations and its cookie-based lock mechanism - Introduce sessionLock module using navigator.locks for concurrency - Simplify sessionStore by inlining retrieve/persist logic within lock - Remove isLockEnabled from SessionStoreStrategy interface - Clean up related tests and fake session store strategy
bd49ace to
e7defdc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7defdcc66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add catch handler to navigator.locks.request() to capture unexpected failures - Send telemetry debug event with error details for 6-month monitoring period
- Restructure expand/renew callback to skip cache assignment when session is in not-started state, preventing stale cache entries - Ensure callback is always invoked regardless of session state
mormubis
left a comment
There was a problem hiding this comment.
All unit tests replace withNativeSessionLock with a synchronous stub — is the real navigator.locks async path only exercised in E2E? If so, a timing bug there would not be caught by unit tests.
Motivation
The old session concurrency mechanism was a custom cookie-based spin-lock — polling for a
lock=cookie entry with retries and delays. It was complex (~136 lines insessionStoreOperations.ts), only enabled in Chromium (isLockEnabled: isChromium()), and left Firefox/Safari without any cross-tab session protection.Changes
sessionStoreOperations.tsand its cookie-based lock mechanismsessionLock.tsusingnavigator.locksfor concurrency — available in all modern browsers (Chrome 69+, Firefox 96+, Safari 15.4+), so this also extends cross-tab session consistency to non-Chromium browserssessionStore.tsby inlining retrieve/persist logic directly within the lock callbackisLockEnabledfromSessionStoreStrategyinterfaceNet: ~554 lines removed, ~137 added.
Test instructions
Unit tests cover the async initialization scenarios:
onReadycallback is deferred until after the lock is releasedChecklist