TanStack / TanStack/router

serverFn.url used as a form action throws "forgot to return a response from your server route handler"

Open
#7,745 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Start

Describe the bug

When calling a server function directly, it works fine, but when calling a server function through .url (e.g. in a form action), it gives an HTTPError (full paths censored):

Error: It looks like you forgot to return a response from your server route handler. If you want to defer to the app router, make sure to have a component set in this route.
    at throwRouteHandlerError (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-server-core@1.169.16_crossws@0.4.8_srvx@0.11.20_/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:187:9)
    ... 5 lines matching cause stack trace ...
    at async file://.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-plugin-core@1.171.19_@tanstack+react-router@1.170.17_react-dom@19.2.7_r_d72b1ab9da4814157965ad4aab276fbb/node_modules/@tanstack/start-plugin-core/dist/esm/vite/dev-server-plugin/plugin.js:79:36 {
  cause: Error: It looks like you forgot to return a response from your server route handler. If you want to defer to the app router, make sure to have a component set in this route.
      at throwRouteHandlerError (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-server-core@1.169.16_crossws@0.4.8_srvx@0.11.20_/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:187:9)
      at getFinalResponse (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-server-core@1.169.16_crossws@0.4.8_srvx@0.11.20_/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:257:7)
      at executeMiddleware (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-server-core@1.169.16_crossws@0.4.8_srvx@0.11.20_/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:325:33)
      at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
      at async startRequestResolver (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-server-core@1.169.16_crossws@0.4.8_srvx@0.11.20_/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:524:50)
      at async Object.fetch (.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+react-start@1.168.27_crossws@0.4.8_srvx@0.11.20__esbuild@0.28.1_react-dom@19._13289cfff4aadcbbf2e856a5b2ef2e8e/node_modules/@tanstack/react-start/dist/plugin/default-entry/server.ts:16:14)
      at async file://.../tanstack-http-error-repro/node_modules/.pnpm/@tanstack+start-plugin-core@1.171.19_@tanstack+react-router@1.170.17_react-dom@19.2.7_r_d72b1ab9da4814157965ad4aab276fbb/node_modules/@tanstack/start-plugin-core/dist/esm/vite/dev-server-plugin/plugin.js:79:36,
  status: 500,
  statusText: undefined,
  headers: undefined,
  data: undefined,
  body: undefined,
  unhandled: true
}
Complete minimal reproducer

https://github.com/sprucepad/tanstack-http-error-repro

Steps to Reproduce the Bug
  1. Run pnpm install && pnpm run dev
  2. Go to localhost:3000, localhost:3001 and localhost:3002
  3. Click the "Through button" buttons in each, see the logs
  4. Click the "Through form" buttons in each, see the errors and logs
Expected behavior

I expected testFn.url to work for forms, as that's what's listed in the docs. Instead, I get an HTTP error.

Screenshots or Videos

https://github.com/user-attachments/assets/f697c066-b3a6-4f68-a92a-a21e9e6a982d

Platform
  • Router / Start Version: Start 1.168.27, Router 1.170.17 (from the template)
  • OS:Linux
  • Browser: Zen (Firefox)
  • Browser Version: 1.21.4b (Firefox 152.0.3)
  • Bundler: Vite
  • Bundler Version: 8.0.0
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal reproducer and run pnpm install && pnpm run dev, then compare the button and form flows across the three localhost ports. Trace the .url request through createStartHandler.ts, which appears in the stack trace. Done means testFn.url works as a form action without the HTTP error while direct calls continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
backend-api-design, full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.