router icon indicating copy to clipboard operation
router copied to clipboard

TypeError: action is not a function

Open JClackett opened this issue 1 month ago โ€ข 3 comments

Which project does this relate to?

Start

Describe the bug

Occasionally im getting TypeError: action is not a function when calling a server function from the client.

TypeError: action is not a function at /Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/server-functions-handler.ts:135:24 at eval (/Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js:80:6) at handleServerAction (/Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js:173:4) at /Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:156:26 at /Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:145:28 at /Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:439:22 at next (/Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:457:16) at startRequestResolver (/Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:248:19) at fetch (/Users/jclackett/Apps/Noa/cf/node_modules/@tanstack/react-start/dist/plugin/default-entry/server.ts:16:14) at EnvRunner.fetch (file:///Users/jclackett/Apps/Noa/cf/node_modules/nitro/dist/runtime/internal/vite/dev-worker.mjs:78:14) Server Fn Error!

Your Example Website or App

https://stackblitz.com/github/tanstack/router/tree/main/examples/react/quickstart-file-based?file=src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

I'm doing my best to create a repro, but it's proving tricky - will continue to work on that but I think its worth tracking this issue anyway as I've seen a few discussions with the same error.

My current setup, and when it fails, is intercepting 401 errors and then calling a server function to refresh the token and replay the original request. Sometimes when this happens the server function fails with the error stated above.

Im using tanstack query on the client, and im wondering if it has something to do with race conditions. it happens when I come back to an inactive tab and tanstack refetches all the stale queries. if the main access token has expired and needs refreshing it tries to call the server function many times and thats causing some error?

Expected behavior

Server functions dont throw TypeError: action is not a function

Screenshots or Videos

No response

Platform

  • Router / Start Version: latest
  • OS: macOS
  • Browser: Chrome
  • Browser Version: latest
  • Bundler: vite
  • Bundler Version: v8 beta

Additional context

https://github.com/TanStack/router/discussions/3027

JClackett avatar Dec 10 '25 11:12 JClackett

๐Ÿ“ CodeRabbit Plan Mode

Generate an implementation plan and agent prompts for this issue.

  • [ ] Create Plan
Examples

๐Ÿ”— Related PRs

TanStack/router#5276 - fix: raw response handling [merged] TanStack/router#5501 - fix: undefined / null serialization [merged] TanStack/router#5513 - fix: no invalidation for server functions in dev [merged] TanStack/router#5650 - fix: fix static server functions [merged] TanStack/router#5935 - fix(start-server-core): deserialize tss context when using formdata [merged]

๐Ÿ‘ค Suggested Assignees

  • schiller-manuel
  • brenelz
  • empotts

๐Ÿงช Issue enrichment is currently in early access.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

coderabbitai[bot] avatar Dec 10 '25 11:12 coderabbitai[bot]

please add a complete reproducer project as a git repo

schiller-manuel avatar Dec 10 '25 19:12 schiller-manuel

yeah working on it!

JClackett avatar Dec 11 '25 10:12 JClackett