TypeError: action is not a function
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
๐ CodeRabbit Plan Mode
Generate an implementation plan and agent prompts for this issue.
- [ ] Create Plan
๐ 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
please add a complete reproducer project as a git repo
yeah working on it!