Repository navigation
fix(reader-access): don't count a re-verified device against the device limit - #651
Conversation
The session suite merged in #647 failed on main (66/140), which made the "No new test failures" check fail for every PR that merged main. Implementation: - store.listSessionsByEmail: accept the real Netlify Blobs list() result ({ blobs: [{ key }] }) as well as a plain key array, and filter keys by the reader's prefix. Previously the real Blobs shape made createSession throw, and a prefix-ignoring adapter leaked other readers' sessions into the device count. - createSession: do not count the device being re-verified towards MAX_CONCURRENT_DEVICES (its session is replaced in place), and serialise creations per reader so concurrent requests cannot all pass the check. Tests (no skips, no removals): - session.test.ts: in-memory Blobs double instead of an auto-mocked store; persist the expiry in the expired-session case. - Await rejects assertions; step past the renewal coalesce window with a faked Date instead of sleeping inside it; expire beyond clock-skew tolerance; measure the rolling window from renewedAt. - security.test.ts: reset rate-limiter state between tests; unpadded base64url fixture; empty tokens must not match; timing tests compare warmed-up interleaved medians (tests/session/helpers/timing.ts). - New regression test for re-verifying on a registered device at the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZe8PHngjvTuY2dcfYm
|
Deployment failed for project thisonetimeonacidcom with the following error: Learn More: https://vercel.com/lightspeedwp?upgradeToPro=build-rate-limit |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
✅ PR Template RoutingBranch prefix: This PR's template has been automatically routed based on the canonical branching strategy defined in lightspeedwp/.github. 📋 Template routing rules:
✨ Automatic routing ensures all PRs follow the organization-wide governance structure. |
📋 Changelog Quality Validation
Status✅ Validation PASSED - No new failures introduced by this PR. No action required. |
|
Deployment failed for project thisonetimeonacidcom with the following error: Learn More: https://vercel.com/lightspeedwp?upgradeToPro=build-rate-limit |
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
|
The red Vercel status on On the current head ( Generated by Claude Code |
|
This pull request is merged. |
PR #653 landed on main with an equivalent repair of the session test suite (Blobs list() handling, prefix filtering, per-email serialisation and the same test corrections). Resolve the conflicts by taking main's version of every overlapping file and drop this branch's duplicate helpers (tests/session/helpers/timing.ts). Re-apply the one change main does not have: createSession no longer counts the reader's existing session on the same device towards MAX_CONCURRENT_DEVICES, with its regression test. CHANGELOG entry narrowed to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZe8PHngjvTuY2dcfYm
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
Summary
The bug
createSessioncounted the reader's existing session on the same device towardsMAX_CONCURRENT_DEVICES. With the default limit of 2, a reader already signed in on two devices who re-verifies on one of them gets409 device_limit_exceeded. That's wrong: the device fingerprint is deterministic, so the new session is stored under the same key and replaces the old one in place. Re-verifying is not adding a device.The fix
netlify/lib/reader-access/session-service.ts: leave sessions with the samedeviceIdout of the active count (one filter condition plus a comment).Changes
netlify/lib/reader-access/session-service.ts: same-device exclusion in the device-limit checktests/session/device-limit-tests.test.ts: regression test "should allow a new session on an already-registered device at the limit"CHANGELOG.md: entry under[Unreleased]→### FixedVerification
main's code (Error: Device limit exceeded) and passes with the fix.npx vitest run tests/session tests/performance/session-latency.test.ts→ 142/142 passed.npx vitest run:main1060 passed / 120 skipped; this branch 1061 passed / 120 skipped (the skips already exist onmain). 0 failures on both.npm run validate:branch-namepasses.Notes for reviewers
api-deployments-free-per-day), not this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01CADHZe8PHngjvTuY2dcfYm