Skip to content

Server Function using inputValidator within zod in co-locate file route is error #5412

Closed

Description

@khanhicetea

Which project does this relate to?

Router

Describe the bug

Server Function using inputValidator within zod in co-locate file route is error

Your Example Website or App

https://github.com/khanhicetea/react-tantan/blob/main/src/routes/(authenticated)/manage/users2.tsx#L26

Steps to Reproduce the Bug or Issue

I put co-locate server function using zod in same-file within Route

import * as z from "zod";

export const $ping = createServerFn()
  .inputValidator(z.string())
  .handler(async (data) => {
    return `pong ${data}`;
  });

Route calling function

<Button
          onClick={() => {
            $ping({ data: "Khanh" }).then(console.log);
          }}
        >
          Ping
        </Button>

Vite.config.ts (I use Nitro v3 vite plugin)

import { nitro } from "nitro/vite";


nitro({
      config: {
        preset: "node-server",
        compressPublicAssets: { gzip: true, brotli: true },
      },
    })

this is error log

serverFnInfo {
  functionName: '$ping_createServerFn_handler',
  importer: [Function: importer]
}
Error: Server function module export not resolved for serverFn ID: src_routes_authenticated_manage_users2_tsx--_ping_createServerFn_handler
    at getServerFnById (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/getServerFnById.js:28:11)
    ... 8 lines matching cause stack trace ...
    at EnvRunner.fetch (file:///Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/[email protected][email protected][email protected]_postgres@_7c970ac4176dd4549bf69e791b257f78/node_modules/nitro-nightly/dist/runtime/internal/vite/dev-worker.mjs:77:14) {
  cause: Error: Server function module export not resolved for serverFn ID: src_routes_authenticated_manage_users2_tsx--_ping_createServerFn_handler
      at getServerFnById (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/getServerFnById.js:28:11)
      at handleServerAction (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js:50:18)
      at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:179:24
      at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:168:26
      at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:462:22
      at next (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:480:16)
      at startRequestResolver (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:267:17)
      at EnvRunner.fetch (file:///Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/[email protected][email protected][email protected]_postgres@_7c970ac4176dd4549bf69e791b257f78/node_modules/nitro-nightly/dist/runtime/internal/vite/dev-worker.mjs:77:14)
      at fetchHandler (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/[email protected][email protected][email protected]_postgres@_7c970ac4176dd4549bf69e791b257f78/node_modules/nitro-nightly/dist/runtime/internal/app.mjs:53:22)
      at EnvRunner.fetch (file:///Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/[email protected][email protected][email protected]_postgres@_7c970ac4176dd4549bf69e791b257f78/node_modules/nitro-nightly/dist/runtime/internal/vite/dev-worker.mjs:77:14),
  status: 500,
  statusText: undefined,
  headers: undefined,
  data: undefined,
  body: undefined,
  unhandled: true
}
fnModule [Object: null prototype] [Module] {
  Route: [Getter],
  '$ping': [Getter]
}

Expected behavior

Should work

BTW : when building and run in production , the error is gone , and separate server functions into separate file works to

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.132.47
  • OS: macOS
  • Bundler: Vite
  • Bundler Version: 7.0.0

Additional context

No response

Activity

  1. added a commit that references this issue on Oct 12, 2025
    ecbafe6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions