Skip to content

Commit d265030

Browse files
ryuhei shimaryuhei shima
authored andcommitted
changed to throw an error
1 parent 7c62581 commit d265030

6 files changed

Lines changed: 18 additions & 51 deletions

File tree

doc/api/inspector.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ added:
520520
-->
521521

522522
* `params` {Object}
523-
* Returns: {Array} An array of errors from each session
524523

525524
This feature is only available with the `--experimental-network-inspection` flag enabled.
526525

@@ -538,7 +537,6 @@ added:
538537
-->
539538

540539
* `params` {Object}
541-
* Returns: {Array} An array of errors from each session
542540

543541
This feature is only available with the `--experimental-network-inspection` flag enabled.
544542

@@ -553,7 +551,6 @@ added:
553551
-->
554552

555553
* `params` {Object}
556-
* Returns: {Array} An array of errors from each session
557554

558555
This feature is only available with the `--experimental-network-inspection` flag enabled.
559556

@@ -569,7 +566,6 @@ added:
569566
-->
570567

571568
* `params` {Object}
572-
* Returns: {Array} An array of errors from each session
573569

574570
This feature is only available with the `--experimental-network-inspection` flag enabled.
575571

@@ -585,7 +581,6 @@ added:
585581
-->
586582

587583
* `params` {Object}
588-
* Returns: {Array} An array of errors from each session
589584

590585
This feature is only available with the `--experimental-network-inspection` flag enabled.
591586

@@ -601,7 +596,6 @@ added:
601596
-->
602597

603598
* `params` {Object}
604-
* Returns: {Array} An array of errors from each session
605599

606600
This feature is only available with the `--experimental-network-inspection` flag enabled.
607601

@@ -616,7 +610,6 @@ added:
616610
-->
617611

618612
* `params` {Object}
619-
* Returns: {Array} An array of errors from each session
620613

621614
This feature is only available with the `--experimental-network-inspection` flag enabled.
622615

@@ -631,7 +624,6 @@ added:
631624
-->
632625

633626
* `params` {Object}
634-
* Returns: {Array} An array of errors from each session
635627

636628
This feature is only available with the `--experimental-network-inspection` flag enabled.
637629

@@ -646,7 +638,6 @@ added:
646638
-->
647639

648640
* `params` {Object}
649-
* Returns: {Array} An array of errors from each session
650641

651642
This feature is only available with the `--experimental-network-inspection` flag enabled.
652643

@@ -705,7 +696,6 @@ added:
705696
* `isLocalStorage` {boolean}
706697
* `key` {string}
707698
* `newValue` {string}
708-
* Returns: {Array} An array of errors from each session
709699

710700
This feature is only available with the
711701
`--experimental-storage-inspection` flag enabled.
@@ -726,7 +716,6 @@ added:
726716
* `storageKey` {string}
727717
* `isLocalStorage` {boolean}
728718
* `key` {string}
729-
* Returns: {Array} An array of errors from each session
730719

731720
This feature is only available with the
732721
`--experimental-storage-inspection` flag enabled.
@@ -749,7 +738,6 @@ added:
749738
* `key` {string}
750739
* `oldValue` {string}
751740
* `newValue` {string}
752-
* Returns: {Array} An array of errors from each session
753741

754742
This feature is only available with the
755743
`--experimental-storage-inspection` flag enabled.
@@ -769,7 +757,6 @@ added:
769757
* `securityOrigin` {string}
770758
* `storageKey` {string}
771759
* `isLocalStorage` {boolean}
772-
* Returns: {Array} An array of errors from each session
773760

774761
This feature is only available with the
775762
`--experimental-storage-inspection` flag enabled.
@@ -788,7 +775,6 @@ added:
788775
* `params` {Object}
789776
* `isLocalStorage` {boolean}
790777
* `storageMap` {Object}
791-
* Returns: {Array} An array of errors from each session
792778

793779
This feature is only available with the
794780
`--experimental-storage-inspection` flag enabled.

lib/inspector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function inspectorWaitForDebugger() {
209209
function broadcastToFrontend(eventName, params = kEmptyObject) {
210210
validateString(eventName, 'eventName');
211211
validateObject(params, 'params');
212-
return emitProtocolEvent(eventName, params);
212+
emitProtocolEvent(eventName, params);
213213
}
214214

215215
const Network = {

src/inspector_agent.cc

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "timer_wrap-inl.h"
3030
#include "util-inl.h"
3131
#include "v8-inspector.h"
32-
#include "v8-isolate.h"
3332
#include "v8-platform.h"
3433

3534
#include "libplatform/libplatform.h"
@@ -744,21 +743,12 @@ class NodeInspectorClient : public V8InspectorClient {
744743
return retaining_context;
745744
}
746745

747-
v8::Local<v8::Array> emitNotification(v8::Local<v8::Context> context,
748-
const StringView& event,
749-
Local<Object> params) {
750-
Isolate* isolate = env_->isolate();
751-
v8::EscapableHandleScope handle_scope(isolate);
752-
v8::Local<v8::Array> results = v8::Array::New(isolate);
746+
void emitNotification(v8::Local<v8::Context> context,
747+
const StringView& event,
748+
Local<Object> params) {
753749
for (const auto& id_channel : channels_) {
754-
v8::TryCatch try_catch(isolate);
755750
id_channel.second->emitNotificationFromBackend(context, event, params);
756-
if (try_catch.HasCaught()) {
757-
Local<Value> exception = try_catch.Exception();
758-
results->Set(context, results->Length(), exception).Check();
759-
}
760751
}
761-
return handle_scope.Escape(results);
762752
}
763753

764754
std::shared_ptr<MainThreadHandle> getThreadHandle() {
@@ -974,10 +964,10 @@ std::unique_ptr<InspectorSession> Agent::ConnectToMainThread(
974964
prevent_shutdown);
975965
}
976966

977-
v8::Local<v8::Array> Agent::EmitProtocolEvent(v8::Local<v8::Context> context,
978-
const StringView& event,
979-
Local<Object> params) {
980-
return client_->emitNotification(context, event, params);
967+
void Agent::EmitProtocolEvent(v8::Local<v8::Context> context,
968+
const StringView& event,
969+
Local<Object> params) {
970+
client_->emitNotification(context, event, params);
981971
}
982972

983973
void Agent::SetupNetworkTracking(Local<Function> enable_function,

src/inspector_agent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class Agent {
7070
void ReportUncaughtException(v8::Local<v8::Value> error,
7171
v8::Local<v8::Message> message);
7272

73-
v8::Local<v8::Array> EmitProtocolEvent(v8::Local<v8::Context> context,
74-
const v8_inspector::StringView& event,
75-
v8::Local<v8::Object> params);
73+
void EmitProtocolEvent(v8::Local<v8::Context> context,
74+
const v8_inspector::StringView& event,
75+
v8::Local<v8::Object> params);
7676

7777
void SetupNetworkTracking(v8::Local<v8::Function> enable_function,
7878
v8::Local<v8::Function> disable_function);

src/inspector_js_api.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "node_external_reference.h"
88
#include "util-inl.h"
99
#include "v8-inspector.h"
10-
#include "v8-local-handle.h"
1110
#include "v8.h"
1211

1312
#include <memory>
@@ -16,7 +15,6 @@ namespace node {
1615
namespace inspector {
1716
namespace {
1817

19-
using v8::Array;
2018
using v8::Context;
2119
using v8::Function;
2220
using v8::FunctionCallbackInfo;
@@ -276,12 +274,10 @@ void EmitProtocolEvent(const FunctionCallbackInfo<Value>& args) {
276274
CHECK(args[1]->IsObject());
277275
Local<Object> params = args[1].As<Object>();
278276

279-
v8::HandleScope handle_scope(env->isolate());
280-
Local<Array> results = env->inspector_agent()->EmitProtocolEvent(
277+
env->inspector_agent()->EmitProtocolEvent(
281278
args.GetIsolate()->GetCurrentContext(),
282279
ToInspectorString(env->isolate(), eventName)->string(),
283280
params);
284-
args.GetReturnValue().Set(results);
285281
}
286282

287283
void SetupNetworkTracking(const FunctionCallbackInfo<Value>& args) {

test/parallel/test-inspector-emit-protocol-event-errors.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,13 @@ const DATA_RECEIVED_ERROR_CASES = [
464464
];
465465

466466
function assertEventErrors(domain, name, params, message) {
467-
const result = inspector[domain][name](params);
468-
assert.strictEqual(
469-
result.length,
470-
1,
471-
`Expected ${domain}.${name} to return exactly one error`,
472-
);
473-
assert.strictEqual(
474-
result[0] instanceof Error,
475-
true,
476-
`Expected ${domain}.${name} to return Error`,
467+
assert.throws(
468+
() => inspector[domain][name](params),
469+
{
470+
message,
471+
},
472+
`Expected ${domain}.${name} to throw`,
477473
);
478-
assert.strictEqual(result[0].message, message);
479474
}
480475

481476
function startRequest(requestId) {

0 commit comments

Comments
 (0)