Skip to content

Commit f0959a4

Browse files
legendecasRafaelGSS
authored andcommitted
inspector: convert event params to protocol without json
Event params object can be converted to inspector protocol directly. This also enables binary data, like `Network.dataReceived`, to be sent in the inspector protocol from JavaScript since JSON representation does not support plain binary data. PR-URL: #57027 Reviewed-By: Kohei Ueno <[email protected]>
1 parent 381f72c commit f0959a4

11 files changed

+344
-160
lines changed

lib/inspector.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88

99
const {
1010
SymbolDispose,
11+
kEmptyObject,
1112
} = require('internal/util');
1213

1314
const {
@@ -192,12 +193,10 @@ function inspectorWaitForDebugger() {
192193
throw new ERR_INSPECTOR_NOT_ACTIVE();
193194
}
194195

195-
function broadcastToFrontend(eventName, params) {
196+
function broadcastToFrontend(eventName, params = kEmptyObject) {
196197
validateString(eventName, 'eventName');
197-
if (params) {
198-
validateObject(params, 'params');
199-
}
200-
emitProtocolEvent(eventName, JSONStringify(params ?? {}));
198+
validateObject(params, 'params');
199+
emitProtocolEvent(eventName, params);
201200
}
202201

203202
const Network = {

0 commit comments

Comments
 (0)