-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Which Cloudflare product(s) does this pertain to?
Wrangler
What version(s) of the tool(s) are you using?
3.95.0
What version of Node are you using?
22.3.0
What operating system and version are you using?
Sequoia 15.1.1
Describe the Bug
This TOML:
name = "browser-rendering-remote"
main = "src/index.js"
compatibility_date = "2024-12-05"
compatibility_flags = ["nodejs_compat"]
[observability]
enabled = true
browser = { binding = "MYBROWSER" }...allows you to run a Worker, but then at runtime, try wrangler dev --remote and you'll see the following runtime error:
[wrangler:inf] GET /favicon.ico 500 Internal Server Error (51ms)
✘ [ERROR] Uncaught (in response) TypeError: Cannot read properties of undefined (reading 'fetch')
at PuppeteerWorkers.launch
(file:///Users/brendan/src/test/browser-rendering-remote/.wrangler/tmp/dev-na2A11/index.js:16857:32)
at Object.fetch
(file:///Users/brendan/src/test/browser-rendering-remote/.wrangler/tmp/dev-na2A11/index.js:18456:56)
at fetchDispatcher
(file:///Users/brendan/src/test/browser-rendering-remote/.wrangler/tmp/dev-na2A11/index.js:18554:19)
at __facade_invokeChain__
(file:///Users/brendan/src/test/browser-rendering-remote/.wrangler/tmp/dev-na2A11/index.js:18516:10)
The browser property above is interpreted as a part of [observability] — even though [observability] has no such property that one can configure.
The browser binding is not defined at runtime, leading to the runtime error.
This is likely to happen a lot because the C3 template we give you back uses []:
workers-sdk/packages/create-cloudflare/templates-experimental/remix/templates/wrangler.toml
Lines 9 to 11 in 0117820
| # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs | |
| [observability] | |
| enabled = true |
so if you drop browser = { binding = "MYBROWSER" } (or similar) under this, then you'll hit some flavor of this issue. And it looks like things are breaking at runtime, which is horribly misleading.
What do we need to do?
- Use TOML syntax that is less likely to cause confusing errors cloudflare-docs#18706 — we should give people example TOML that is less prone to this footgun
- We should consider starting to loudly raise a warning (not error) in local dev if we see properties within
wrangler.tomlthat we know are not supported as part of the given binding/thing being configured. Ex: if I see that the observability binding has abrowserproperty configured — we should know that that....isn't a thing and warn you — right? - We should likely audit docs for other examples of places where we can do (1)
- In the Browser Rendering puppeteer fork, we should be able to check if the binding was actually passed in — and if not, throw a loud and clear error that explains
- Anything else?
Please provide a link to a minimal reproduction
https://github.com/irvinebroque/browser-rendering-remote
h/t @rita3ko finding this