Skip to content

Commit b7beb33

Browse files
authored
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 044d69a commit b7beb33

11 files changed

+344
-160
lines changed

lib/inspector.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if (!hasInspector)
2424

2525
const EventEmitter = require('events');
2626
const { queueMicrotask } = require('internal/process/task_queues');
27+
const { kEmptyObject } = require('internal/util');
2728
const {
2829
isUint32,
2930
validateFunction,
@@ -189,12 +190,10 @@ function inspectorWaitForDebugger() {
189190
throw new ERR_INSPECTOR_NOT_ACTIVE();
190191
}
191192

192-
function broadcastToFrontend(eventName, params) {
193+
function broadcastToFrontend(eventName, params = kEmptyObject) {
193194
validateString(eventName, 'eventName');
194-
if (params) {
195-
validateObject(params, 'params');
196-
}
197-
emitProtocolEvent(eventName, JSONStringify(params ?? {}));
195+
validateObject(params, 'params');
196+
emitProtocolEvent(eventName, params);
198197
}
199198

200199
const Network = {

0 commit comments

Comments
 (0)