Skip to content

TypeError: action is not a function #6056

@JClackett

Description

@JClackett

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

#3027

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions