500 Server Error After Successful Deployment
# pages-help
m
Hello, I have a very simple Qwik.js CRUD site which connects to PlanetScale via Drizzle and the @planetscale/database serverless driver. The site works locally both through both the dev and preview commands, where preview is a 'build' running locally. The site has three pages, home, create and read. Once deployed to Cloudflare, visiting the 'read' page causes a 500 server error, and the create page fails to post data to PlanetScale. There are no errors, or anything in the logs. I don't know how to indentify what's going wrong. drizzle-planetscale.pages.dev Account Id: 0a8e870be7816c5fe869f27205a441f0 GitHub: https://github.com/MattHeslington/drizzle-planetscale Any help very much appreciated. Cheers, Matt
I've tested deploying the same code using Vercel Edge Functions and it works fine, so it would appear a Cloudflare issue
w
I'd look at your Function logs and see if there's an exception being thrown in there
r
Hi @Matt _* Where you able to get any insight into the 500 response? I am trying to deploy a Remix Run app that is using Drizzle and Planetscale to Cloudflare Pages, and I think I am getting the same response. Server returns 500 with this error message and that's it: {"message":"Unexpected Server Error"}
@Walshy | Pages I don't see any logs when I visit the url that you linked to. I just get routed to my
Workers & Pages Overview
page. In the network tab though, I do see the 500 response with the {"message":"Unexpected Server Error"} Seems like a couple of people are having some sort of trouble with Planetscale with Drizzle on Cloudflare Pages. It works fine locally, but when deployed any DB calls get this 500 response on Cloudflare Pages
w
Follow what the toast says, you need to select your project and your deployment
without logs, i couldn't tell you why it's failing
i've not used planetscale + drizzle but have used planetscale on Pages without issue
r
@Walshy | Pages Thanks for the help. I was able to track down where the functions log real time, and I have this log from the 500 response. "exceptions": [], "logs": [ { "message": [ "Error: The 'cache' field on 'RequestInitializerDict' is not implemented." ], "level": "error", "timestamp": 1685006555499 } ], https://cdn.discordapp.com/attachments/1109832546897907753/1111223577606377472/message.txt
w
So there's a lib using
fetch
with the
cache
property which isn't supported on Workers
that should also fail locally though
guessing Miniflare allowed it, if you use wrangler 3 or --experimental-local it'd probably be caught
r
I am using
wrangler 2.20.0
w
yeah so using
--experimental-local
should catch this locally
r
When I changed
"wrangler": "wrangler pages dev ./public --local --persist",
to
"wrangler": "wrangler pages dev ./public --experimental-local --persist"
I get
✘ [ERROR] local worker: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@miniflare/tre' imported from /Users/rptrainor/gits/lightup-cloudflare/node_modules/wrangler/wrangler-dist/cli.js
in the terminal when I try to start it locally
Maybe I should update to wrangler 3?
It's a Remix app. These are the current scripts, I usually start locally with
npm run dev
"scripts": { "build": "remix build", "dev:remix": "remix watch", "dev:wrangler": "cross-env NODE_ENV=development npm run wrangler", "dev": "npm-run-all build --parallel \"dev:*\"", "start": "cross-env NODE_ENV=production npm run wrangler", "typecheck": "tsc", "wrangler": "wrangler pages dev ./public --local --persist", "generate": "drizzle-kit generate:sqlite --schema=./app/db/schema.ts --out=./drizzle", "up": "drizzle-kit up:sqlite", "db:push": "drizzle-kit push:mysql" },
Okay, I updated to wrangler 3 and now get the error on local as well: Error: The 'cache' field on 'RequestInitializerDict' is not implemented. at checkedFetch2 (a8mfhauf7ya.js:27:36) at postJSON (a8mfhauf7ya.js:21859:109) at Connection.execute (a8mfhauf7ya.js:21832:192) at PlanetScalePreparedQuery.execute (a8mfhauf7ya.js:21660:33) at MySqlSelect.execute (a8mfhauf7ya.js:21346:79) at QueryPromise.then (a8mfhauf7ya.js:20306:17)
@Walshy | Pages I solved it. If you hear of anyone else having this problem the temporary fix to up downgrade to
"@planetscale/database": "^1.6.0",
at least until @planetscale/database is able to fix to problem with 1.7.0 https://github.com/planetscale/database-js/pull/102#issuecomment-1499549618 https://github.com/cloudflare/workerd/issues/698
Thank you for the help!
3 Views