You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash "TypeError: serverFn is not a function" when calling server function with nested server function multiple times #6451
Sometimes TanStack Start crashes on this line with the following error when calling a specific server function multiple times at nearly the same time:
return serverFn(...args)
^
TypeError: serverFn is not a function
at Object.fn (/Users/ulrichstark/Desktop/tanstack-repro-crash-serverfn-is-not-a-function/node_modules/@tanstack/start-server-core/src/createSsrRpc.ts:18:12)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async client (/Users/ulrichstark/Desktop/tanstack-repro-crash-serverfn-is-not-a-function/node_modules/@tanstack/start-client-core/src/createServerFn.ts:786:21)
at async callNextMiddleware (/Users/ulrichstark/Desktop/tanstack-repro-crash-serverfn-is-not-a-function/node_modules/@tanstack/start-client-core/src/createServerFn.ts:282:24)
at async Object.assign (/Users/ulrichstark/Desktop/tanstack-repro-crash-serverfn-is-not-a-function/node_modules/@tanstack/start-client-core/src/createServerFn.ts:120:26)
git clone https://github.com/ulrichstark/tanstack-repro-crash-serverfn-is-not-a-function
cd tanstack-repro-crash-serverfn-is-not-a-function
npm i
npx vite
Expected behavior
Don't crash
Screenshots or Videos
No response
Platform
Router / Start Version: 1.154.7
OS: macOS
Browser: Chrome
Browser Version: 143.0.7499.170
Bundler: Vite
Bundler Version: 7.3.1
Additional context
Clicking the button in my repro calls the server function uploadDocumentServerFn 100 times. This server function calls the imported server function analyzeDocumentServerFn. And this server function uses and imports getCookies from @tanstack/react-start and zodTextFormat from openai.
Sometimes the button doesn't trigger the crash, so just click it again until the dev server crashes.
I don't think I'm able to remove more stuff from my repro project while still getting the dev server to crash on button click. I also noticed that when removing the @tailwindcss/vite plugin from vite.config.ts, the crash goes away.
Reacted by IK, Vinícius Bittencourt, Alex Iurkov, Prisco, uap-dev, zachrog and Michael Sorens
In our real world project, where my minimal repro of this issues comes from, I also sometimes see the following error under the same circumstances:
Server Fn Error!
TypeError: action is not a function
at eval (/real-world-project/node_modules/@tanstack/start-server-core/src/server-functions-handler.ts:152:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async eval (/real-world-project/node_modules/@tanstack/start-server-core/src/server-functions-handler.ts:75:17)
at async handleServerAction (/real-world-project/node_modules/@tanstack/start-server-core/src/server-functions-handler.ts:73:20)
at async next (/real-world-project/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:165:16)
at async startRequestResolver (/real-world-project/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:314:21)
at async Object.fetch (/real-world-project/node_modules/@tanstack/react-start/src/default-entry/server.ts:16:14)
at async Object.fetch (/real-world-project/node_modules/@tanstack/react-start/src/default-entry/server.ts:16:14)
at async file:///real-world-project/node_modules/@tanstack/start-plugin-core/dist/esm/dev-server-plugin/plugin.js:112:30
Having the same issue in my project. Calling a server function (it returns a session from '@tanstack/react-start/server') in my root router loader throws the same error occasionally.
Reacted by Ulrich Stark, Jayden(LaiJiahao), Vinícius Bittencourt, Kevin Minh and Alex Iurkov
When it starts happening, it happens on every page load.
I'm running my dev server inside an Ubuntu WSL on Win 11. Sometimes the error goes away after closing VSCode + terminating the WSL (wsl -t ubuntu) + restarting VSCode & the dev server. However, that doesn't always help & when it doesn't I have to restart my whole computer to make the error go away...
I wasn't able yet to figure out what server fn causes this and therefore can't tell whether or not I'm also dealing with nested server fns like the OP.
Activity
ulrichstark commentedon Jan 23, 2026
In our real world project, where my minimal repro of this issues comes from, I also sometimes see the following error under the same circumstances:
So my issue might be related to #6056.
thiisiriya commentedon Jan 23, 2026
Having the same issue in my project. Calling a server function (it returns a session from '@tanstack/react-start/server') in my root router loader throws the same error occasionally.
Kevinminh commentedon Feb 5, 2026
Same
kno-raziel commentedon Feb 10, 2026
Getting this error when saving files.
dufia commentedon Feb 28, 2026
I do struggle with it from time to time on HMR, seems like clearing circular deps helps
CombeeMike commentedon Mar 3, 2026
I'm also experiencing this error sometimes.
When it starts happening, it happens on every page load.
I'm running my dev server inside an Ubuntu WSL on Win 11. Sometimes the error goes away after closing VSCode + terminating the WSL (
wsl -t ubuntu) + restarting VSCode & the dev server. However, that doesn't always help & when it doesn't I have to restart my whole computer to make the error go away...I wasn't able yet to figure out what server fn causes this and therefore can't tell whether or not I'm also dealing with nested server fns like the OP.