fix: txn cookie accumulation#2748
Conversation
…d targeted cleanup
…nd targeted cleanup
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe PR blocks transaction creation from Next.js prefetches, evicts accumulated transaction cookies, adds cookie-size warnings, updates transaction-cookie encoding and tests, forwards client options, and documents practices for avoiding 431 errors. ChangesTransaction Cookie Controls
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2748 +/- ##
==========================================
+ Coverage 88.11% 88.32% +0.21%
==========================================
Files 79 79
Lines 11105 11191 +86
Branches 2296 2320 +24
==========================================
+ Hits 9785 9885 +100
+ Misses 1276 1262 -14
Partials 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@EXAMPLES.md`:
- Around line 4048-4051: The transaction-cookie eviction check must include the
incoming cookie size: update the logic calculating txnBytes or the cap condition
to evaluate existing transaction-cookie bytes plus newCookieValue’s serialized
size against the 3500-byte limit. Preserve FIFO eviction and leave
non-transaction cookies untouched, and add a boundary test covering a new cookie
that causes the combined total to reach or exceed the limit.
In `@README.md`:
- Around line 193-194: Align the login-link guidance in README.md with the
corresponding recommendation in EXAMPLES.md. Choose one tested approach—prefer
plain <a> links until the RSC-navigation detector is fixed, or consistently
document Link with prefetch disabled—and update the conflicting documentation so
both files prescribe the same behavior.
In `@src/utils/request.ts`:
- Around line 27-35: The isNonNavigationalRequest function incorrectly treats
the generic Accept header as a prefetch signal. Remove that check or require an
explicit prefetch indicator, then update the login snippets in EXAMPLES.md at
lines 237-238 and 4057-4068 to reflect the corrected navigation behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a92bef5-5000-46b6-8039-d5704cdc15da
📒 Files selected for processing (13)
EXAMPLES.mdREADME.mdsrc/server/auth-client.test.tssrc/server/auth-client.tssrc/server/client.tssrc/server/mfa-popup.test.tssrc/server/session/stateless-session-store.test.tssrc/server/session/stateless-session-store.tssrc/server/transaction-store.test.tssrc/server/transaction-store.tssrc/server/txn-cookie-accumulation.test.tssrc/test/utils.tssrc/utils/request.ts
💤 Files with no reviewable changes (1)
- src/server/client.ts
📋 Changes
Fixes unbounded _txn* transaction-cookie accumulation that produces 431 Request Header Fields Too Large, and adds a warning for the other main cause of oversized request headers - a large session cookie.
Docs (EXAMPLES.md + README.md)
- use
<a>/<Link prefetch={false}>— not<Link href="/auth/login">- prefer withPageAuthRequired over middleware redirects
- recommends lowering transactionCookie.maxAge if in-flight logins are being evicted too aggressively.
📎 References
🎯 Testing
Summary by CodeRabbit