Skip to content

Add WebSocket lifecycle, frame, and frame-error diagnostic events for DevTools Protocol support #4673

@islandryu

Description

@islandryu

This would solve...

Node.js is currently developing WebSocket inspection support in DevTools, but at the moment it can only handle WebSocket open and close events.

Reference:
nodejs/node#59404

I’d like to request further support for the data needed by the DevTools inspector.

The implementation should look like...

1. undici:websocket:created

{ websocket, url }

Required for Network.webSocketCreated.
undici:websocket:open fires after the handshake, so we need an event that fires when the WebSocket object is created.

Spec:
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-webSocketCreated

2. undici:websocket:handshakeRequest

{ websocket }

Required forNetwork.requestWillBeSent.

We need a hook for the moment when the HTTP upgrade request is sent.

Spec:
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-requestWillBeSent

3. undici:websocket:frameSent undici:websocket:frameRecieved

{ websocket, opcode, mask, payloadData }

Required for:

  • Network.webSocketFrameSent
  • Network.webSocketFrameReceived

Spec:
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-webSocketFrameSent
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-webSocketFrameReceived
https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-WebSocketFrame

4. WebSocket frame error event

Required for Network.webSocketFrameError.

Undici currently has socket_error,
but it does not indicate which WebSocket instance the error belongs to—unlike other WebSocket events.

I have also considered...

Additional context

I understand that some of these events may require consideration, but I’d appreciate it if you could start by supporting the ones that are feasible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions