cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers

Home Page:https://blog.cloudflare.com/workerd-open-source-workers-runtime/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

devtools/vscode debugging fails kj/compat/http.c with Message is too large (>1MB)

kavika-1 opened this issue · comments

Using either the remix cloudflare workers or pages template out of box on WSL2 linux. Trying to debug locally, setting a breakpoint. Breakpoint is hit, but then emits the error listed below, after which the session is broken. Chrome devtools and vscode run into the same issue.

After investigating, it seems to have to have to do with the size of certain chunks that remix emits, as well as map files, which are clearly greater than 1MB. Apparently these are sent via WebSocket? Minifying the build reduced that file to under 300K, and debugging breakpoints works again.

Can't find a way to ask remix to chunk that piece any smaller. Would it make sense when running locally to allow larger messages to improve the worker/pages developer experience? Even if behind an option/flag?

✘ [ERROR] workerd/jsg/util.c++:281: error: e = kj/compat/http.c++:5618: failed: WebSocket protocol error; protocolError.statusCode = 1009; protocolError.description = Message is too large: 2157260 > 1048576

stack: /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@35bf930 /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@35bfb7a /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@48f24cf /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@2c10ba0 /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@35dddc0 /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@2c10ba0 /home/david/github/plg-perf-app-cfp/node_modules/@cloudflare/workerd-linux-64/bin/workerd@2e1932c; sentryErrorContext = jsgInternalError

Oh this looks like an easy fix -- #1573.

Wow - so much appreciated!

I still get this in v1.20240404.0, which is super-strange. The inspector service closes down and devtools (chrome / vscode) hangs. From the code, it looks like it should be fixed.

workerd/jsg/util.c++:291: error: e = kj/compat/http.c++:5754: failed: WebSocket protocol error; protocolError.statusCode = 1009; protocolError.description = Message is too large: 1111947 > 1048576

Also, when the error is reported, it prints garbage, since the id is no longer valid:

✘ [ERROR] workerd/server/server.c++:1230: info: Inspector client detached [|�^k�NF0�@^o�m�NF �v�,�	]

After a bit of debugging - it seems this happens for capn-protoed cdp messages between workerd:s?. I have a setup with a bunch of DurableObjects (<20) - if I reduce the number of registered namespaces, everything works.