Skip to content

[Start] SSR build fails when calling function returned by createServerOnlyFn #6643

@b-mendoza

Description

@b-mendoza

Which project does this relate to?

Start

Describe the bug

After upgrading to @tanstack/start-plugin-core@1.158.2, the SSR build fails with:

[tanstack-start-core::server-fn:ssr] createServerOnlyFn() must be called with a function!

This appears related to changes in #6599.

Your Example Website or App

https://stackblitz.com/~/github.com/b-mendoza/create_server_only_fn-error?file=src/routes/deferred.tsx:L5-L22

Steps to Reproduce the Bug or Issue

  1. Create a file with this pattern:
import { createServerOnlyFn } from "@tanstack/react-start";

const myFn = createServerOnlyFn(() => ({ hello: "world" }));
const result = myFn();
  1. Run the build script
  2. The client build succeeds, but the SSR build crashes with: createServerOnlyFn() must be called with a function!

Expected behavior

myFn() should execute normally during SSR build. Calls to functions returned by createServerOnlyFn should not trigger this error.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.159.5 (regression introduced in 1.158.2)
  • OS: Linux (WSL2)
  • Bundler: vite
  • Bundler Version: 7.3.1

Additional context

A workaround is to inline the call:

const result = createServerOnlyFn(() => ({ hello: "world" }))();

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