Worker preview websocket changed

Cloudflare worker previews use websockets to communicate with the devtools panel.

Using that websocket endpoint you can get log messages and errors about workers when testing, I use this in pytest-cloudflare-worker. See the code here.

This is great.

Unfortunately, the format of specific messages has changed recently. In particular preview has been removed from messages with method: 'Runtime.consoleAPICalled'. This makes showing such log messages to users much more difficult - I’d have to send another Runtime.getProperties message for every argument of every log message to get a good preview :frowning:

Please could you:

  • tell me if there’s some message I can send when first connecting to the websocket that means the preview is included again?
  • Tell me if there’s any formal documentation of this endpoint?
  • consider formalising this websocket endpoint so it doesn’t change unexpectedly and has docs

@KentonVarda I imagine this is your domain?

Hi @samuelcolvin,

The WebSocket protocol here is the Chrome Devtools debugging protocol. It is the same protocol used to inspect Chrome and Node.js. It is documented here.

The server side of this protocol is provided by V8 itself. If something about it changed, it’s because V8 changed. We don’t really control this. The client side UI, too, actually comes straight from Chrome – you can find the code on github.

To be honest, I actually have no idea how this protocol works! :sweat_smile:


That’s really helpful, thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.