@@ -335,21 +335,28 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
335335
336336 std::vector<uint8_t > cbor_buffer;
337337 ConvertJSONToCBOR (crdtp::SpanFrom (raw_message), &cbor_buffer);
338- Dispatchable dispatchable (crdtp::SpanFrom (cbor_buffer));
338+ // TODO(legendecas): The fallthrough callback captures a raw `this`. That is
339+ // safe only while every command in node_protocol_config.json is
340+ // synchronous. An async command stores the callback and may invoke it
341+ // after this session is gone, so add a lifetime guard before adding one.
342+ Dispatchable dispatchable (
343+ crdtp::SpanFrom (cbor_buffer),
344+ std::string_view (),
345+ [this ](int call_id,
346+ crdtp::span<uint8_t > method,
347+ crdtp::span<uint8_t > serialized_message,
348+ std::string_view associated_data) {
349+ per_process::Debug (DebugCategory::INSPECTOR_SERVER ,
350+ " [inspector] method not found\n " );
351+ node_dispatcher_->SendMethodNotFound (call_id, method);
352+ });
339353 crdtp::span<uint8_t > method = dispatchable.Method ();
340354 if (v8_inspector::V8InspectorSession::canDispatchMethod (
341355 StringView (method.data (), method.size ()))) {
342356 session_->dispatchProtocolMessage (message);
343357 return ;
344358 }
345- UberDispatcher::DispatchResult result =
346- node_dispatcher_->Dispatch (dispatchable);
347- if (!result.MethodFound ()) {
348- per_process::Debug (DebugCategory::INSPECTOR_SERVER ,
349- " [inspector] method not found\n " );
350- // Fall through to send a method not found error.
351- }
352- result.Run ();
359+ node_dispatcher_->Dispatch (dispatchable);
353360 }
354361
355362 void schedulePauseOnNextStatement (const std::string& reason) {
@@ -442,13 +449,6 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
442449 sendMessageToFrontend (json);
443450 }
444451
445- // crdtp::FrontendChannel
446- void FallThrough (int call_id,
447- crdtp::span<uint8_t > method,
448- crdtp::span<uint8_t > message) override {
449- DCHECK (false );
450- }
451-
452452 std::unique_ptr<protocol::RuntimeAgent> runtime_agent_;
453453#ifndef V8_USE_PERFETTO
454454 std::unique_ptr<protocol::TracingAgent> tracing_agent_;
0 commit comments