Failed Deployment

Similar to this post: https://discord.com/channels/595317990191398933/1236032759923736668 I have tried deploying in vain, the deploy succeeds when using npm run deploy but ultimately fails with no logs or indication of the is causing the problem. The deployment id for the last deploy is 554ebc67-f85b-433f-8e65-9a9a53ea0259
25 Replies
Nolan
Nolanβ€’5mo ago
Hey there! It looks like we've got a edge_deployment_failed error with the following output.
deploy_worker_failed:Uncaught Error: Dynamic require of "node:crypto" is not supported at functionsWorker-0.4400651895596901.js:12:9 at functionsWorker-0.4400651895596901.js:72396:19 in ../node_modules/@remix-run/node/dist/sessions/fileStorage.js at functionsWorker-0.4400651895596901.js:18:50 in __require2 at functionsWorker-0.4400651895596901.js:72898:23 in ../node_modules/@remix-run/node/dist/index.js at functionsWorker-0.4400651895596901.js:18:50 in __require2 at functionsWorker-0.4400651895596901.js:74025:27 in ../build/server/index.js at functionsWorker-0.4400651895596901.js:15:56 in __init at functionsWorker-0.4400651895596901.js:74194:5 in [[path]].ts at functionsWorker-0.4400651895596901.js:15:56 in __init at functionsWorker-0.4400651895596901.js:74204:5 in ../.wrangler/tmp/pages-NNfL6Q/functionsRoutes-0.3802553210814601.mjs
deploy_worker_failed:Uncaught Error: Dynamic require of "node:crypto" is not supported at functionsWorker-0.4400651895596901.js:12:9 at functionsWorker-0.4400651895596901.js:72396:19 in ../node_modules/@remix-run/node/dist/sessions/fileStorage.js at functionsWorker-0.4400651895596901.js:18:50 in __require2 at functionsWorker-0.4400651895596901.js:72898:23 in ../node_modules/@remix-run/node/dist/index.js at functionsWorker-0.4400651895596901.js:18:50 in __require2 at functionsWorker-0.4400651895596901.js:74025:27 in ../build/server/index.js at functionsWorker-0.4400651895596901.js:15:56 in __init at functionsWorker-0.4400651895596901.js:74194:5 in [[path]].ts at functionsWorker-0.4400651895596901.js:15:56 in __init at functionsWorker-0.4400651895596901.js:74204:5 in ../.wrangler/tmp/pages-NNfL6Q/functionsRoutes-0.3802553210814601.mjs
blindChicken
blindChickenβ€’5mo ago
How do I fix this? I have added the nodejs_compat compatibility flags?
Walshy
Walshyβ€’5mo ago
you'll want that require to be an import, esbuild doesn't support dynamic requires. Sadly that looks to be in remix's code
blindChicken
blindChickenβ€’5mo ago
The require is from a third party package, dotenv. Which I am using to get the keys for my CF-Turnstile widget
Walshy
Walshyβ€’5mo ago
../node_modules/@remix-run/node/dist/sessions/fileStorage.js
looks like it's in remix not dotenv but either way, it looks like this wouldn't work anyway as it's trying to use files (fs) can you switch to a different session storage? they have a built-in createWorkersKVSessionStorage but you can also use like cookie
blindChicken
blindChickenβ€’5mo ago
I'm guessing that this is being cause by Turnstile likely for the proof of space mechanism it uses?
Walshy
Walshyβ€’5mo ago
turnstile isn't using remix nor sessions remix is a web framework Seems like you're using it + auth sessions backed by file storage
blindChicken
blindChickenβ€’5mo ago
I'm not using any of that. I used CF template for remix. The website is super simple, an info page and a contact form. The contact form has Turnstile on it. I'm guessing that because of SSR, it is causing Turnstile to do stuff on the server which should only be done on the client.
Walshy
Walshyβ€’5mo ago
This has nothing to do with turnstile, it's just the way remix is setup
blindChicken
blindChickenβ€’5mo ago
Note that, in order for it to deploy in my console with wrangler I needed to go and manually add the node: prefix to the require in the dotenv, cookiesignature and `stream-slice packages.
Walshy
Walshyβ€’5mo ago
sounds like a lot of node dependencies haha Not sure if dotenv works in Workers since that usually loads from .env - no fs in Workers. You should have those in .dev.vars or wrangler.toml
blindChicken
blindChickenβ€’5mo ago
✘ [ERROR] Could not resolve "os"

../node_modules/dotenv/lib/main.js:3:19:
3 β”‚ const os = require('os')
β•΅ ~~~~

The package "os" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.
✘ [ERROR] Could not resolve "os"

../node_modules/dotenv/lib/main.js:3:19:
3 β”‚ const os = require('os')
β•΅ ~~~~

The package "os" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.
Walshy
Walshyβ€’5mo ago
yeah ^ You'll have to de-nodeify this project
blindChicken
blindChickenβ€’5mo ago
That is likely the problem. I was basing myself on this post: https://www.jacobparis.com/content/remix-cloudflare-pages
Jacob Paris
Deploy a new Remix app to Cloudflare Pages
Cloudflare doesn't use Node.js. Use wrangler as your dev server. Use .dev.vars instead of .env. Make sure you set up wrangler.toml correctly.
blindChicken
blindChickenβ€’5mo ago
How? Are there an resources?
Want results from more Discord servers?
Add your server