Skip to content

Commit 339d2a9

Browse files
committed
src: adopt FallthroughCallback signature of Dispatchable
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
1 parent fb1a34a commit 339d2a9

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

‎src/inspector_agent.cc‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)