Deploy on cloudflare always returns 500
I have an app which runs a absolutely fine locally. No issue whatsoever.
Then when I deploy it to cloudflare it is just returning 500 and prints absolutely no log.
https://hraj-eu.capaj.workers.dev/
here you can see all I get
when I tail the worker:
how do you even begin to debug this?
Locally I get the same behaviour when something throws on module load. For example when I forget an ENV var.
For deployment I have all the env vars. I triplechecked.
Is there any way to like force nitro or tanstack router into some super verbose logging mode so that I can at least see a few logs before it dies?
Or ideally return the error in the json payload it is responding with?
12 Replies
equal-aqua•3w ago
There’s a few threads about the same issue. It would be great to get out-of-the-box better logging to help identify these issues
The most common cause seems to be deploying via CI to Cloudflare, requires confirming VITE client environment variables into the BUILD settings of your project
ambitious-aquaOP•3w ago
I am deploying from my local
variable-lime•3w ago
@Cloudflare (Partner)
ambitious-aquaOP•3w ago
@BootStepper very helpful, thanks so much!
I figured it out.
for me it was
https://github.com/paralleldrive/cuid/issues/297
GitHub
version 3 breaks on cloudflare workers: Uncaught Error: Disallowed ...
https://github.com/capaj/faktorio/actions/runs/19192226702/job/54868243201 ✘ [ERROR] A request to the Cloudflare API (/accounts/***/workers/scripts/faktorio-api/versions) failed. Uncaught Error: Di...
ambitious-aquaOP•3w ago
@Cloudflare (Partner) would be good to figure out why on your end it does not show any errors at deploy.
Because when I deploy a regular react app to CF pages with wrangler it shows up-does not even let me deploy.
For tanstack start it deploys, just dies on CF
wise-white•2w ago
Sorry about the dev/prod mismatch here. This is related to https://github.com/cloudflare/workers-sdk/issues/9489. This behaves differently in dev because Vite evaluates the modules as functions so we'll need to find a way of emulating the production behaviour.
GitHub
cloudflare/workers-sdk
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
like-gold•2w ago
I had 500s deploying to cloudflare and ignorantly didnt realize that I needed env variables in the Build's Variables and Secrets. I had all my env variables in the regular Variables and Secrets, but didnt realize I needed my VITE_ ones in Build specifically... maybe this will help someone reading this in the future
equal-aqua•5d ago
@James Opstad we’ve had 5+ reports on discord from people with failed Cloudflare deploys due to this issue, would it be at all possible to make the cloudflare deployment/tooling detect this, or provide some indication this is the issue?
wise-white•3d ago
Can you provide links to these reports? 500 errors can happen for lots of reasons so need to make sure they have the same cause.
wise-white•3d ago
@capaj Are you able to open an issue with a reproduction in workers-sdk ? This should error when you try to deploy so we should fix that first if it doesn't.
GitHub
GitHub - cloudflare/workers-sdk: ⛅️ Home to Wrangler, the CLI f...
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
equal-aqua•3d ago
Let me dig up a few:
https://discord.com/channels/719702312431386674/1421410804636323940/1421410804636323940
(e.g. there’s no visibility or docs to know this is the case)
https://discord.com/channels/719702312431386674/1430992910979039314/1431013582857965728
the root cause of this error was a misconfigured env var, but the out of the box deployment gives you no way to get the logs with enough detail