Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Dynamic require of "util" is not supported in pages _worker.js #7672

Open
brachkow opened this issue Jan 6, 2025 · 0 comments
Open
Labels
bug Something that isn't working

Comments

@brachkow
Copy link

brachkow commented Jan 6, 2025

Which Cloudflare product(s) does this pertain to?

Pages, Workers Runtime, Wrangler

What versions are you using?

wrangler 3.99.0, node v22.12.0

What operating system and version are you using?

Mac 15.0.1

Please provide a link to a minimal reproduction

No response

Describe the Bug

I'm building an app that has frontend part, and backend inside a page worker. When I'm adding stripe as dependency I'm getting this error from running wrangler pages dev ./dist

Uncaught Error: Dynamic require of "util" is not supported

I build worker using this esbuild config:

esbuild --bundle --sourcemap ./server/index.ts --format=esm --platform=node --outfile=./dist/_worker.js --watch

My wrangler config has such compat configuration

"compatibility_date": "2024-11-06",
"compatibility_flags": ["nodejs_compat"],

What's interesting — the error does not appear in standard worker, only in cf pages _worker.js

Please provide any relevant error logs

service core:user:app: Uncaught Error: Dynamic require of "util" is not supported

at null.<anonymous> (bundledWorker-0.720856741514531.js:21:9)
at null.<anonymous> (bundledWorker-0.720856741514531.js:24141:17) in

../../node_modules/.pnpm/[email protected]/node_modules/combined-stream/lib/combined_stream.js
at null. (bundledWorker-0.720856741514531.js:3220:50) in __require2
at null. (bundledWorker-0.720856741514531.js:33164:26) in
../../node_modules/.pnpm/[email protected]/node_modules/form-data/lib/form_data.js
at null. (bundledWorker-0.720856741514531.js:3220:50) in __require2
at null. (bundledWorker-0.720856741514531.js:58175:32)

@brachkow brachkow added the bug Something that isn't working label Jan 6, 2025
@brachkow brachkow changed the title 🐛 BUG: 🐛 BUG: Dynamic require of "util" is not supported Jan 6, 2025
@brachkow brachkow changed the title 🐛 BUG: Dynamic require of "util" is not supported 🐛 BUG: Dynamic require of "util" is not supported in pages _worker.js Jan 6, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant