-
Notifications
You must be signed in to change notification settings - Fork 435
Fix updateSession and header overwrite issues
#2330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t; perviously this was setting a SetCookie header with maxAge=0 for each call to updateSession()
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2330 +/- ##
==========================================
+ Coverage 86.90% 87.61% +0.71%
==========================================
Files 37 37
Lines 4070 4086 +16
Branches 799 809 +10
==========================================
+ Hits 3537 3580 +43
+ Misses 530 503 -27
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
updateSession setting unnecessary Max-Age=0 cookies
…er() was called with multiple entries of set-ccokie header key, leading to the latest entries overwriting old entries, leading to missing cookies
…/auth0/nextjs-auth0 into debug/updateSession-empty-cookie
updateSession setting unnecessary Max-Age=0 cookiesupdateSession and header overwrite issues
|
@claude please review this PR |
|
Claude finished @tusharpandey13's task —— View job Code Review Complete
Overall Assessment
|
📋 Changes
This PR implements three complementary fixes to resolve updateSession reliability issues:
Fixed race condition in timestamp calculations - Eliminated inconsistent
maxAgevalues by using the sameupdatedAttimestamp throughoutcalculateMaxAge()instead of callingthis.epoch()twice, preventingMax-Age=0cookies from timing inconsistenciessrc/server/session/abstract-session-store.tsImplemented conditional legacy cookie cleanup - Added existence check before deleting legacy cookies to prevent unnecessary
Max-Age=0cookies appearing in response headers duringupdateSession()callssrc/server/session/stateless-session-store.tssrc/server/session/stateless-session-store.test.ts(updated test mocks)Fixed header overwrite in Pages Router - Resolved session chunk loss by collecting all
set-cookieheaders into an array before setting them, preventingres.setHeader()from overwriting multiple cookiessrc/server/client.tssrc/server/updateSession-header-fix.test.ts(comprehensive test suite)📎 References
Fixes: #2316
🎯 Testing
Automated:
getChunkedCookie()properly for legacy cookie scenariosupdateSession-header-fix.test.tscovering multiple set-cookie header scenarios, legacy cookie deletion, and edge casesManual:
updateSession(req, res, session)with chunked session dataconsole.log(res.getHeaders())immediately after theupdateSession()call'set-cookie': ['appSession=; Path=/; Max-Age=0'](unnecessary deletion) or missing session chunks (header overwrite)Max-Age=0deletion cookies