From ee9c8cf0cbb77341c56b12efdc871401bd3212d2 Mon Sep 17 00:00:00 2001 From: Shima Ryuhei <65934663+islandryu@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:09:14 +0900 Subject: [PATCH] inspector: initial support websocket inspection Refs: https://github.com/nodejs/node/issues/53946 PR-URL: https://github.com/nodejs/node/pull/59404 Reviewed-By: Chengzhong Wu --- doc/api/inspector.md | 42 +++++++ lib/inspector.js | 4 + lib/internal/inspector/network_undici.js | 37 ++++++ src/inspector/network_agent.cc | 87 +++++++++++++++ src/inspector/network_agent.h | 7 ++ src/inspector/node_protocol.pdl | 35 ++++++ test/common/websocket-server.js | 105 ++++++++++++++++++ .../test-inspector-emit-protocol-event.js | 30 ++++- .../test-inspector-network-websocket.js | 63 +++++++++++ 9 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 test/common/websocket-server.js create mode 100644 test/parallel/test-inspector-network-websocket.js diff --git a/doc/api/inspector.md b/doc/api/inspector.md index 95ddad0e93..939351ec38 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -602,6 +602,48 @@ This feature is only available with the `--experimental-network-inspection` flag Broadcasts the `Network.loadingFailed` event to connected frontends. This event indicates that HTTP request has failed to load. +### `inspector.Network.webSocketCreated([params])` + + + +* `params` {Object} + +This feature is only available with the `--experimental-network-inspection` flag enabled. + +Broadcasts the `Network.webSocketCreated` event to connected frontends. This event indicates that +a WebSocket connection has been initiated. + +### `inspector.Network.webSocketHandshakeResponseReceived([params])` + + + +* `params` {Object} + +This feature is only available with the `--experimental-network-inspection` flag enabled. + +Broadcasts the `Network.webSocketHandshakeResponseReceived` event to connected frontends. +This event indicates that the WebSocket handshake response has been received. + +### `inspector.Network.webSocketClosed([params])` + + + +* `params` {Object} + +This feature is only available with the `--experimental-network-inspection` flag enabled. + +Broadcasts the `Network.webSocketClosed` event to connected frontends. +This event indicates that a WebSocket connection has been closed. + ### `inspector.NetworkResources.put`