Skip to content

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Dec 20, 2025

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 20, 2025

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

Possibly related PRs

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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The 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.

@birkskyum birkskyum changed the title fix(start-server-core): use public api event.res fix(start-server-core): use public h3-v2 api event.res Dec 20, 2025
@nx-cloud
Copy link

nx-cloud bot commented Dec 20, 2025

View your CI Pipeline Execution ↗ for commit 1230cb0

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 18s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 27s View ↗

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 20, 2025

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

@birkskyum birkskyum marked this pull request as ready for review December 20, 2025 22:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 8a20521 and 1230cb0.

📒 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.

@birkskyum birkskyum merged commit 82ac628 into main Dec 20, 2025
6 checks passed
@birkskyum birkskyum deleted the fix(start-server-core)--use-public-api-for-event.res branch December 20, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants