From 9b8c5326dfab7c5577f665b845e053e944e88531 Mon Sep 17 00:00:00 2001 From: islandryu Date: Thu, 7 Aug 2025 22:49:18 +0900 Subject: [PATCH 1/4] inspector: initial support websocket inspection Refs: https://github.com/nodejs/node/issues/53946 --- doc/api/inspector.md | 42 +++++++ lib/inspector.js | 4 + lib/internal/inspector/network_undici.js | 33 +++++ src/inspector/network_agent.cc | 87 ++++++++++++++ src/inspector/network_agent.h | 7 ++ src/inspector/node_protocol.pdl | 35 ++++++ test/common/websocket-server.js | 113 ++++++++++++++++++ .../test-inspector-emit-protocol-event.js | 30 ++++- .../test-inspector-network-websocket.js | 63 ++++++++++ 9 files changed, 413 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 95ddad0e9363a9..939351ec383161 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`