Skip to content

Commit e10ef27

Browse files
legendecastargos
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 <kohei.ueno119@gmail.com>
1 parent 4413ce7 commit e10ef27

11 files changed

Lines changed: 344 additions & 160 deletions

‎lib/inspector.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if (!hasInspector)
2424

2525
constEventEmitter=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
thrownewERR_INSPECTOR_NOT_ACTIVE();
190191
}
191192

192-
functionbroadcastToFrontend(eventName,params){
193+
functionbroadcastToFrontend(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
constNetwork={

0 commit comments

Comments
 (0)