Larger bundle size for Workers Paid not applying?
Sample deployment: 21570bb8-d9dc-4359-8804-3bb12b5e4d8b
I'm deploying a Remix app on Cloudflare Functions/Pages using a project created with the Cloudflare CLI. After adding a new library, my application will no longer deploy. (It deploys successfully locally, but silently fails in the Cloudflare console. @Erisa helped me understand that silent failures mean the bundle size exceeds the free limits.)
I couldn't figure out lowering the bundle size, so I gave in and upgraded to Workers Paid for the 10 MB deployment limit... but deploys are still failing silently.
npx wrangler pages functions build
locally produces a 5.7 MB file, which should be well under the 10MB limit. Any tips?5 Replies
Not all silent errors are bundle size unfortunately, the current issue is that these silent errors require someone from Cloudflare to look them up.
This one apparently is
Uncaught ReferenceError: Buffer is not defined [..] in ../node_modules/.pnpm/csv-stringify@6.4.6/node_modules/csv-stringify/lib/api/index.js
which indicates csv-stringify is trying to import Buffer in a way that won't work: https://developers.cloudflare.com/workers/runtime-apis/nodejs/buffer/
You need to add the nodejs_compat compatability flag and ensure node:buffer is imported instead of Buffer (which admittedly is not easy when a dependancy is doing it)I see, thank you! I understand how to fix that. If I switch to deploying from Github, does that wind up showing all the errors? (Is the silent failure for local deploys?)
If I switch to deploying from Github, does that wind up showing all the errors? (Is the silent failure for local deploys?)That's correct, the message will show up just fine for deploys using Pages CI integration with GitHub (or GitLab)
Thank you! I'll switch to that. Last dumb question: For bundle size, is there a command I can run locally to get the full functions bundle with the size the way Cloudflare measures it? I've been using
npx wrangler pages functions build
, but it's still larger than the 1MB allowed.That command is the right one but when uploading its compressed with
gzip
and the compressed size is the one that matters