Skip to content

Crash "TypeError: serverFn is not a function" when calling server function with nested server function multiple times #6451

Open

Description

@ulrichstark

Which project does this relate to?

Start

Describe the bug

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)

Your Example Website or App

https://github.com/ulrichstark/tanstack-repro-crash-serverfn-is-not-a-function

Steps to Reproduce the Bug or Issue

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.

Activity

  1. ulrichstark commented on Jan 23, 2026

    @ulrichstark
    ContributorAuthor

    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
    

    So my issue might be related to #6056.

  2. thiisiriya commented on Jan 23, 2026

    @thiisiriya

    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.

  3. Kevinminh commented on Feb 5, 2026

    @Kevinminh

    Same

  4. kno-raziel commented on Feb 10, 2026

    @kno-raziel

    Getting this error when saving files.

  5. dufia commented on Feb 28, 2026

    @dufia

    I do struggle with it from time to time on HMR, seems like clearing circular deps helps

  6. CombeeMike commented on Mar 3, 2026

    @CombeeMike

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions