Skip to content
Source
Sign inSign up
TanStack/router

fix(start-server-core): use public h3-v2 api event.res #6162

Mergedbirkskyum(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/6162/headmerged by birkskyum(GitHub profile, opens in a new tab)

Summary by CodeRabbit

Refactor

  • Improved internal code patterns for request/response handling to use standard property access instead of symbol-based access
  • Strengthened type safety in response property handling by removing optional chaining assumptions
✏️ Tip: You can customize this high-level summary in your review settings.
    1. Walkthrough

      This PR refactors response handling in start-server-core by replacing internal h3 response symbol access with the public event.res property and removing optional chaining operators when accessing response status properties, assuming getResponse() consistently returns a defined Response object.

      Changes

      Cohort / File(s)Summary
      Response handling refactoring
      packages/start-server-core/src/request-response.ts
      Replaces internal h3 response symbol with public event.res property in getResponse(); removes ts-expect-error annotation and Symbol usage
      Status property access updates
      packages/start-server-core/src/server-functions-handler.ts
      Removes optional chaining (`?.`) operators from response.status and response.statusText access patterns; updates error handling path to use direct property access while maintaining 500 default fallback

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~10 minutes

      • Both files contain straightforward, repetitive refactoring with consistent patterns
      • Changes are mostly mechanical replacements of access operators without new logic
      • However, review should verify response object is always defined as expected after getResponse() calls
      • TanStack/router#5973: Modifies the same response handling functions in opposite ways (switches between internal and public APIs for h3 response access)
      • TanStack/router#5959: Directly related changes to getResponse() and server-functions-handler response property access patterns
      • TanStack/router#5276: Modifies response handling in server-functions-handler.ts, related to response object interactions

      Poem

      🐰 Response calls now flow so clean, With public paths where none had been, No symbols hidden, no chains to break, Just straightforward access for goodness' sake! thump thump ✨

      Pre-merge checks and finishing touches

      ❌ Failed checks (1 warning)
      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 50.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
      ✅ Passed checks (2 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title clearly summarizes the main change: replacing internal h3 symbol access with the public event.res API in the start-server-core package.
      ✨ Finishing touches
      • 📝 Generate docstrings
        🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `fix(start-server-core)--use-public-api-for-event.res`

      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
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core

    3. birkskyum(GitHub profile, opens in a new tab) changed the title

    4. View your CI Pipeline Execution ↗ for commit 1230cb00b24595260baf0de286f8fca472656c0a

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded12m 18sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded27sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-12-20 22:34:47 UTC

    5. More templates

      @tanstack/arktype-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6162

      @tanstack/directive-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@6162

      @tanstack/eslint-plugin-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6162

      @tanstack/history

      npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6162

      @tanstack/nitro-v2-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6162

      @tanstack/react-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6162

      @tanstack/react-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6162

      @tanstack/react-router-ssr-query

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6162

      @tanstack/react-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6162

      @tanstack/react-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6162

      @tanstack/react-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6162

      @tanstack/router-cli

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6162

      @tanstack/router-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6162

      @tanstack/router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6162

      @tanstack/router-devtools-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6162

      @tanstack/router-generator

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6162

      @tanstack/router-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6162

      @tanstack/router-ssr-query-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6162

      @tanstack/router-utils

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6162

      @tanstack/router-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6162

      @tanstack/server-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@6162

      @tanstack/solid-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6162

      @tanstack/solid-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6162

      @tanstack/solid-router-ssr-query

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6162

      @tanstack/solid-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6162

      @tanstack/solid-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6162

      @tanstack/solid-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6162

      @tanstack/start-client-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6162

      @tanstack/start-plugin-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6162

      @tanstack/start-server-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6162

      @tanstack/start-static-server-functions

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6162

      @tanstack/start-storage-context

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6162

      @tanstack/valibot-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6162

      @tanstack/virtual-file-routes

      npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6162

      @tanstack/vue-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6162

      @tanstack/vue-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6162

      @tanstack/vue-router-ssr-query

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6162

      @tanstack/vue-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6162

      @tanstack/vue-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6162

      @tanstack/vue-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6162

      @tanstack/zod-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6162

      commit: 1230cb0

    6. Actionable comments posted: 0

      🧹 Nitpick comments (1)
      packages/start-server-core/src/server-functions-handler.ts (1)

      221-231: Consider consistent fallback defaults for response status.

      The removal of optional chaining on response is correct since getResponse() now returns a defined object. However, there's an inconsistency in how response.status is handled:

      • Success paths (lines 224, 255, 265): Use response.status directly without fallback
      • Error path (line 305): Uses response.status ?? 500 with explicit fallback

      While the Response constructor accepts undefined status and defaults to 200, consider adding explicit ?? 200 to success paths for consistency and clarity. This would make the intended behavior more explicit and align with the error path's pattern.

      🔎 Optional refactor for consistent defaults
             return new Response(
               nonStreamingBody ? JSON.stringify(nonStreamingBody) : undefined,
               {
      -          status: response.status,
      +          status: response.status ?? 200,
                 statusText: response.statusText,
                 headers: {

      Apply similar changes at lines 255 and 265 for consistency.

      Also applies to: 254-261, 264-267, 303-311

      📜 Review details

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 8a205211c51751a4a84db47935fd53df4ef99387 and 1230cb00b24595260baf0de286f8fca472656c0a.

      📒 Files selected for processing (2)
      • packages/start-server-core/src/request-response.ts (1 hunks)
      • packages/start-server-core/src/server-functions-handler.ts (4 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/server-functions-handler.ts
      • 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/server-functions-handler.ts
      • packages/start-server-core/src/request-response.ts
      🔇 Additional comments (1)
      packages/start-server-core/src/request-response.ts (1)

      340-343: Confirmed: event.res is the documented public API in h3-v2.

      The change correctly uses h3-v2's public API instead of internal symbols. The getResponse() function safely returns event.res, which is documented and stable.

Sign in to join this conversation.