TypeError: action is not a function
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
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
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/server-functions-handler.ts around line 135 and the related request flow in src/createStartHandler.ts, both named in the stack trace. Use the quickstart-file-based StackBlitz example and the 401/token-refresh scenario as starting points for a reproducible case, consulting discussion 3027 for related reports. Done means the intermittent server-function call no longer produces TypeError: action is not a function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript, vite
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100