T
TanStack6mo ago
conscious-sapphire

POST server functions returning 500

This happens only when deployed to Vercel (locally it's working fine) The relevant log I'm getting: TypeError: f.split is not a function
23 Replies
fair-rose
fair-rose6mo ago
can you please provide a complete minimal example as a git repo?
fascinating-indigo
fascinating-indigo6mo ago
yeah Im getting that today too... narrowed it down to a server function importing a react-email email @mariusflorescu are you by chance using react-email? same deal on my end though, works fine locally but gives me same error on Vercel would love to know if you got it figured out
conscious-sapphire
conscious-sapphireOP6mo ago
yes, it’s because of react-email i honestly don’t know what to do
fascinating-indigo
fascinating-indigo6mo ago
I put put my resend / react-email imports in a separate helper file. This at least keeps my page from erroring. Still can't send emails using the react components from react-email, but can use html & text without issue im working around it by just makign a html only version of my email I guess
conscious-sapphire
conscious-sapphireOP6mo ago
@JJ Rise is your setup a mono-repo?
fascinating-indigo
fascinating-indigo6mo ago
Yes
conscious-sapphire
conscious-sapphireOP6mo ago
Mhm I think that might be the issue. This works just fine in a simple app, but not in the monorepo have you managed to find a way to solve the issue @JJ Rise ?
passive-yellow
passive-yellow6mo ago
If you can provide a reproduction, I can help looking into that There is sooo many ways to do monorepos that without a reproduction it's hard to help (build/no build, tspath alias/workspace/project reference, one entry per lib/multiple entry per lib, etc)
fascinating-indigo
fascinating-indigo6mo ago
Sorry @mariusflorescu I have no yet. Just using html and text as a simple workaround for now
fair-rose
fair-rose6mo ago
@JJ Rise any chance you can provide a reproducer?
conscious-sapphire
conscious-sapphireOP5mo ago
GitHub
GitHub - mariusflorescu/tanstack-start-resend-issue
Contribute to mariusflorescu/tanstack-start-resend-issue development by creating an account on GitHub.
conscious-sapphire
conscious-sapphireOP5mo ago
I included the steps to reproduce Sorry... took long but i didn't have time to do it since it took some time
passive-yellow
passive-yellow5mo ago
I'll try to look at it tonight or this weekend! Thanks for the repro
conscious-sapphire
conscious-sapphireOP5mo ago
thanks. you might need also to do export ENV_VAR= before running the pnpm start
passive-yellow
passive-yellow5mo ago
So I've looked at the repro, but I don't have a resend account so I wasn't able to reproduce the issue :/ I've tried to remove the resend part, and I don't seems to have an issue Maybe it's the template part that vinxi is trying to parse ? But that's my biggest clue so far, nothing weird regarding resolution config, tsconfig path aliases are properly setup Could you provide a full stacktrase ?
conscious-sapphire
conscious-sapphireOP5mo ago
But resend is free @Nicolas Beaussart I’m going to give tou the full stacktrace
[request error] [unhandled] [POST] http://localhost:3000/_server/src_server_sendEmail_ts--sendEmailFn_createServerFn_handler?createServerFn
TypeError: f.split is not a function
at l (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5241:15)
... 8 lines matching cause stack trace ...
at async Server.toNodeHandle (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1854:7) {
cause: TypeError: f.split is not a function
at l (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5241:15)
at file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5235:69
at file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5244:3
at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async fe$1 (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4962:11)
at async Object.ae [as handler] (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4949:10)
at async file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1583:19
at async Object.callAsync (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4022:16)
at async Server.toNodeHandle (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1854:7),
statusCode: 500,
fatal: false,
unhandled: true,
statusMessage: undefined,
data: undefined
}
[request error] [unhandled] [POST] http://localhost:3000/_server/src_server_sendEmail_ts--sendEmailFn_createServerFn_handler?createServerFn
TypeError: f.split is not a function
at l (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5241:15)
... 8 lines matching cause stack trace ...
at async Server.toNodeHandle (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1854:7) {
cause: TypeError: f.split is not a function
at l (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5241:15)
at file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5235:69
at file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/build/sendEmail-DRTXW1ph.mjs:5244:3
at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async fe$1 (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4962:11)
at async Object.ae [as handler] (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4949:10)
at async file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1583:19
at async Object.callAsync (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:4022:16)
at async Server.toNodeHandle (file:///Users/DIRNAME/tanstack-start-resend-issue/apps/web/.output/server/chunks/nitro/nitro.mjs:1854:7),
statusCode: 500,
fatal: false,
unhandled: true,
statusMessage: undefined,
data: undefined
}
I guess so too that the issue its caused by the parsing of the React code. Text/raw html work fine. Only when I put a template this fails. But is it vinxi or nitro that have this issue
passive-yellow
passive-yellow5mo ago
I know. But my kid is awake and I didn't had time to set one up before the end of nap time 😅
conscious-sapphire
conscious-sapphireOP5mo ago
I can create you one API key if you want for 10-15 mins 😋 but my stacktrace will be the exact same as yours Or another though is that somehow the import is failing for the template. It is very weird that this fails only in monorepo situation.
passive-yellow
passive-yellow5mo ago
So. One thing you can try is to build the library with the template, so when nitro or vinxi reads the template lib, it's no longer jsx
conscious-sapphire
conscious-sapphireOP5mo ago
we should somehow get some more detailed logs… any idea how? @JJ Rise are you using tailwind for templates?
fascinating-indigo
fascinating-indigo5mo ago
indeed
conscious-sapphire
conscious-sapphireOP5mo ago
So the guys from resend are opening an issue. The root cause seems to be the tailwind stuff. We can close this topic here. Will ping you once I get an update.
fascinating-indigo
fascinating-indigo5mo ago
awesome, thank you @mariusflorescu !!

Did you find this page helpful?