Skip to content

fix: preserve multi-valued Set-Cookie headers in route handler ISR cache#758

Open
NathanDrake2406 wants to merge 1 commit intocloudflare:mainfrom
NathanDrake2406:fix/route-handler-cache-set-cookie
Open

fix: preserve multi-valued Set-Cookie headers in route handler ISR cache#758
NathanDrake2406 wants to merge 1 commit intocloudflare:mainfrom
NathanDrake2406:fix/route-handler-cache-set-cookie

Conversation

@NathanDrake2406
Copy link
Copy Markdown
Contributor

Summary

  • buildAppRouteCacheValue() used headers.forEach() which overwrites same-key entries, dropping all but the last Set-Cookie header from cached responses
  • The restore path (buildRouteHandlerCachedResponse) already handles string[] correctly — only the store path was broken
  • Uses getSetCookie() to preserve all Set-Cookie headers as a string[], matching the pattern in worker-utils.ts and prod-server.ts

Test plan

  • Test: route handler with multiple Set-Cookie headers — all preserved after cache round-trip
  • Test: route handler with zero Set-Cookie headers — no regression
  • Existing app-router tests pass (275 tests)
  • Existing ISR cache tests pass (42 tests)

buildAppRouteCacheValue() used headers.forEach() which overwrites same-key
entries, causing all but the last Set-Cookie header to be silently dropped
from cached route handler responses. Uses getSetCookie() to preserve all
Set-Cookie headers as a string array, matching the pattern used elsewhere
in the codebase (worker-utils.ts, prod-server.ts).
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@758

commit: 95b28b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant