fix(start-server-core): bump h3 from v2.0.1-rc.2 to v2.0.1-rc.6 #6161
main fromrefs/pull/6161/head·merged by birkskyum(GitHub profile, opens in a new tab) Update from 2.0.1-rc.2 to 2.0.1-rc.6
There's a change to header merging behavior that causes test failure (title "multiple Set-Cookie headers are preserved on redirect"), starting from 2.0.1-rc.3
Implemented fix that keeps just the Set-Cookie headers in redirect, to maintain existing behavior.
Summary by CodeRabbit#
- Chores
- Updated h3 dependency to version 2.0.1-rc.6
- Bug Fixes
- Improved response header and Set-Cookie handling so cookies and headers from the request context are consistently applied to responses (no public API changes)
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
View your CI Pipeline Execution ↗ for commit bc6b53ffb4eda7d4aa86260927d6ad65d67334f2
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 6m 54s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 28s View ↗
☁️ Nx Cloud last updated this comment at
2025-12-21 00:38:01UTCMore templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6161@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@6161@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6161@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6161@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6161@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6161@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6161@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6161@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6161@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6161@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6161@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6161@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6161@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6161@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6161@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6161@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6161@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6161@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6161@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6161@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@6161@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6161@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6161@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6161@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6161@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6161@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6161@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6161@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6161@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6161@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6161@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6161@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6161@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6161@tanstack/vue-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6161@tanstack/vue-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6161@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6161@tanstack/vue-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6161@tanstack/vue-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6161@tanstack/vue-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6161@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6161commit:
bc6b53fbirkskyum(GitHub profile, opens in a new tab) changed the title
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/start-server-core/src/request-response.ts (1)
91-98: Consider simplifying the header manipulation logic.The code deletes all Set-Cookie headers from the response and then re-appends both the response's original cookies and the event's cookies. Since the response cookies are being re-added in the same order, the deletion step is redundant. You could simplify by just appending the event cookies directly.
🔎 Simplified approach
const responseSetCookies = getSetCookieValues(response.headers) - response.headers.delete('set-cookie') - for (const cookie of responseSetCookies) { - response.headers.append('set-cookie', cookie) - } for (const cookie of eventSetCookies) { response.headers.append('set-cookie', cookie) }Note: This assumes the intended behavior is to append event cookies after response cookies. If a different ordering is required, the current approach would be necessary.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 75e1387159c99aed6e09fe0bb3520047c814247a and e5582dad0a56dca32c4f8b72348a0a12e745359b.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/start-server-core/package.json(1 hunks)packages/start-server-core/src/request-response.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript strict mode with extensive type safety for all code
Files:
packages/start-server-core/src/request-response.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Implement ESLint rules for router best practices using the ESLint plugin router
Files:
packages/start-server-core/src/request-response.ts
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace protocol
workspace:*for internal dependencies in package.json filesFiles:
packages/start-server-core/package.json
🧠 Learnings (2)
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5732 File: packages/start-client-core/src/client/hydrateStart.ts:6-9 Timestamp: 2025-11-02T16:16:24.898Z Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.Applied to files:
packages/start-server-core/package.json
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-12-06T15:03:07.223Z Learning: Applies to **/package.json : Use workspace protocol `workspace:*` for internal dependencies in package.json filesApplied to files:
packages/start-server-core/package.json
🔇 Additional comments (7)
packages/start-server-core/src/request-response.ts (6)
62-64: LGTM!The type correctly models the optional
getSetCookie()method that may be available on Headers objects in some runtime environments.
66-70: LGTM!The
MaybePromiseutility type andisPromiseLiketype guard are correctly implemented and follow TypeScript best practices.
72-79: LGTM!The function correctly prefers
getSetCookie()when available and falls back toheaders.get(). The fallback may only retrieve a single Set-Cookie value if multiple exist andgetSetCookie()is unavailable, but this is a known limitation of the Headers API.
101-119: LGTM with a note on error handling.The function correctly handles both synchronous and asynchronous handler results. The logic properly checks for Response instances before merging headers.
Note: If
mergeEventResponseHeadersthrows an error in the Promise chain, the Promise will reject. This is likely acceptable sinceh3_toResponsewould need to handle such errors anyway, but consider whether explicit error handling would be beneficial.
121-132: LGTM!The integration of
attachResponseHeaderscorrectly wraps the handler result before converting it to a Response viah3_toResponse. This enables automatic propagation of Set-Cookie headers from the event context to response objects for both synchronous and asynchronous handlers.
81-84: Clarify why event-context cookies are excluded from successful responses and simplify the header merge logic.The
if (response.ok) returncheck at lines 82-83 is intentional for handling non-2xx responses (redirects and errors), as shown by the e2e test "test that multiple Set-Cookie headers are not lost during redirect." However, response.ok is true for status codes 200-299, which means event-context cookies (set via h3'ssetCookie) are excluded from successful responses.Either document why 2xx responses should not merge event cookies, or remove this condition to preserve them consistently. Additionally, simplify lines 92-95: the
delete()followed by re-appending response cookies is redundant—directly append only event cookies to achieve the same result.packages/start-server-core/package.json (1)
82-82: h3@2.0.1-rc.6 version is valid and not deprecated.The specified version exists in the npm registry with no deprecation flag. The pre-release progression from 2.0.1-rc.2 to 2.0.1-rc.6 is supported by available versions.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between e5582dad0a56dca32c4f8b72348a0a12e745359b and bc6b53ffb4eda7d4aa86260927d6ad65d67334f2.
📒 Files selected for processing (1)
packages/start-server-core/src/request-response.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript strict mode with extensive type safety for all code
Files:
packages/start-server-core/src/request-response.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Implement ESLint rules for router best practices using the ESLint plugin router
Files:
packages/start-server-core/src/request-response.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (5)
packages/start-server-core/src/request-response.ts (5)
62-66: LGTM - Well-defined utility types.The type definitions appropriately support both modern environments with
getSetCookie()and fallback scenarios. TheMaybePromisetype enables promise-aware header attachment.
101-119: LGTM - Robust promise-aware header attachment.The implementation correctly handles both synchronous and asynchronous handler results:
- Promises are resolved before header merging
- Non-Response values pass through unmodified
- Type safety is preserved with proper generic handling
130-130: LGTM - Clean integration of header merging.The modification correctly positions header attachment before response conversion, enabling Set-Cookie propagation from the event context to the final Response. The approach maintains backward compatibility since merging is conditional on response status.
81-84: The implementation is correct. Theresponse.okcheck intentionally limits header merging to non-successful responses (3xx redirects and 4xx/5xx errors), which aligns with the test case "multiple Set-Cookie headers are preserved on redirect." Successful responses (2xx) don't require event cookie merging.
72-79: Understand Set-Cookie fallback limitations due to Fetch API constraints.The fallback at lines 77-78 uses
headers.get('set-cookie'), which returns only a single Set-Cookie value per the Fetch standard (Headers objects cannot represent multiple Set-Cookie headers). This is an API-level constraint, not a code issue—the function correctly prioritizesgetSetCookie()when available, and the fallback is the only option in environments without this method. Document this limitation if needed.packages/start-server-core/src/request-response.ts lines 92 to 98@@ -61,0 +78,21 @@78+ return value ? [value] : []79+}80+81+function mergeEventResponseHeaders(response: Response, event: H3Event): void {82+ if (response.ok) {83+ return84+ }85+86+ const eventSetCookies = getSetCookieValues(event.res.headers)87+ if (eventSetCookies.length === 0) {88+ return89+ }90+91+ const responseSetCookies = getSetCookieValues(response.headers)92+ response.headers.delete('set-cookie')93+ for (const cookie of responseSetCookies) {94+ response.headers.append('set-cookie', cookie)95+ }96+ for (const cookie of eventSetCookies) {97+ response.headers.append('set-cookie', cookie)98+ }⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
🏁 Script executed:
find . -name "request-response.ts" -type f | head -5Repository: TanStack/router
Length of output: 111
🏁 Script executed:
cat -n packages/start-server-core/src/request-response.ts | sed -n '80,110p'Repository: TanStack/router
Length of output: 1105
🏁 Script executed:
cat -n packages/start-server-core/src/request-response.ts | head -50Repository: TanStack/router
Length of output: 1870
🏁 Script executed:
cat -n packages/start-server-core/src/request-response.ts | sed -n '50,90p'Repository: TanStack/router
Length of output: 1509
Response headers mutation will fail at runtime for immutable Response objects.
The code directly mutates
response.headersusingdelete()andappend(). However, Fetch API Response headers are immutable when created via Response.error(), Response.redirect(), or received from fetch(), throwing a TypeError if mutation is attempted. Since themergeEventResponseHeadersfunction receives a generic Response parameter with unknown origin, this approach will fail for responses with immutable headers.Instead of mutating headers directly, create a new Response with merged headers:
const newHeaders = new Headers(response.headers) newHeaders.delete('set-cookie') for (const cookie of responseSetCookies) { newHeaders.append('set-cookie', cookie) } for (const cookie of eventSetCookies) { newHeaders.append('set-cookie', cookie) } return new Response(response.body, { status: response.status, statusText: response.statusText, headers: newHeaders })Alternatively, check if headers are mutable before attempting mutation, with fallback to response reconstruction for immutable headers.
🤖 Prompt for AI Agents
In packages/start-server-core/src/request-response.ts around lines 92 to 98, the code mutates response.headers (delete/append) which will throw for immutable Response headers; instead create a new Headers from response.headers, remove the existing set-cookie entries on that new Headers, append responseSetCookies and eventSetCookies to it, and return a new Response preserving response.body, status, and statusText (and any other needed response options) with the merged Headers; alternatively detect header mutability and fall back to this reconstruction when headers are immutable.birkskyum(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Walkthrough#
Updates h3-v2 dependency and adds internal cookie/header utilities that merge Set-Cookie from the event into handler responses, with promise-aware attachment so both synchronous and asynchronous handler results receive merged headers.
Changes#
packages/start-server-core/package.jsonh3-v2fromnpm:h3@2.0.1-rc.2tonpm:h3@2.0.1-rc.6.packages/start-server-core/src/request-response.tsMaybePromise,isPromiseLike),getSetCookieValues,mergeEventResponseHeaders, andattachResponseHeaders; wrappedrequestHandlerresults to mergeSet-Cookiefrom the event into responses (works for sync and async results).Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
attachResponseHeadersand its integration withrequestHandlerSet-Cookievalues (includinggetSetCookiepath)Possibly related PRs#
packages/start-server-core/src/request-response.ts; related to attaching/merging response headers.request-response.ts, which may intersect with cookie/header propagation changes.Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.
❤️ Share