-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
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
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/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/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/nitro-nightly@3.0.0-20251007-155759-75b985fb_drizzle-orm@0.44.6_kysely@0.28.7_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/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/getServerFnById.js:28:11)
at handleServerAction (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js:50:18)
at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:179:24
at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:168:26
at /Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:462:22
at next (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:480:16)
at startRequestResolver (/Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/@tanstack+start-server-core@1.132.48_crossws@0.4.1_srvx@0.8.14_/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:267:17)
at EnvRunner.fetch (file:///Users/khanhicetea/dev/labs/tantan/node_modules/.pnpm/nitro-nightly@3.0.0-20251007-155759-75b985fb_drizzle-orm@0.44.6_kysely@0.28.7_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/nitro-nightly@3.0.0-20251007-155759-75b985fb_drizzle-orm@0.44.6_kysely@0.28.7_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/nitro-nightly@3.0.0-20251007-155759-75b985fb_drizzle-orm@0.44.6_kysely@0.28.7_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