Skip to content

Commit

Permalink
inspector: convert event params to protocol without json
Browse files Browse the repository at this point in the history
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 <kohei.ueno119@gmail.com>
  • Loading branch information
legendecas authored Feb 24, 2025
1 parent 044d69a commit b7beb33
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 160 deletions.
9 changes: 4 additions & 5 deletions lib/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (!hasInspector)

const EventEmitter = require('events');
const { queueMicrotask } = require('internal/process/task_queues');
const { kEmptyObject } = require('internal/util');
const {
isUint32,
validateFunction,
Expand Down Expand Up @@ -189,12 +190,10 @@ function inspectorWaitForDebugger() {
throw new ERR_INSPECTOR_NOT_ACTIVE();
}

function broadcastToFrontend(eventName, params) {
function broadcastToFrontend(eventName, params = kEmptyObject) {
validateString(eventName, 'eventName');
if (params) {
validateObject(params, 'params');
}
emitProtocolEvent(eventName, JSONStringify(params ?? {}));
validateObject(params, 'params');
emitProtocolEvent(eventName, params);
}

const Network = {
Expand Down
Loading

0 comments on commit b7beb33

Please sign in to comment.