diff options
author | Eugene Ostroukhov <eostroukhov@gmail.com> | 2019-07-27 02:38:15 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-31 07:17:27 +0300 |
commit | 7435dc8b2ba2bed4d6a8c1b6474f21c7219b3238 (patch) | |
tree | cc4e2a2a067721e7744da872e72914f46ab3277d /src/inspector_agent.cc | |
parent | c3b2111423c73769680734e1891b43cb3eb9cd4c (diff) |
inspector: report all workers
Main thread (the one that WS endpoint connects to) should be able
to report all workers.
PR-URL: https://github.com/nodejs/node/pull/28872
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r-- | src/inspector_agent.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index a1cdc606fe8..f4c3dbfdfdc 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -237,8 +237,10 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, tracing_agent_ = std::make_unique<protocol::TracingAgent>(env, main_thread_); tracing_agent_->Wire(node_dispatcher_.get()); - worker_agent_ = std::make_unique<protocol::WorkerAgent>(worker_manager); - worker_agent_->Wire(node_dispatcher_.get()); + if (worker_manager) { + worker_agent_ = std::make_unique<protocol::WorkerAgent>(worker_manager); + worker_agent_->Wire(node_dispatcher_.get()); + } runtime_agent_ = std::make_unique<protocol::RuntimeAgent>(); runtime_agent_->Wire(node_dispatcher_.get()); } @@ -246,8 +248,10 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, ~ChannelImpl() override { tracing_agent_->disable(); tracing_agent_.reset(); // Dispose before the dispatchers - worker_agent_->disable(); - worker_agent_.reset(); // Dispose before the dispatchers + if (worker_agent_) { + worker_agent_->disable(); + worker_agent_.reset(); // Dispose before the dispatchers + } runtime_agent_->disable(); runtime_agent_.reset(); // Dispose before the dispatchers } @@ -670,6 +674,9 @@ class NodeInspectorClient : public V8InspectorClient { } std::shared_ptr<WorkerManager> getWorkerManager() { + if (!is_main_) { + return nullptr; + } if (worker_manager_ == nullptr) { worker_manager_ = std::make_shared<WorkerManager>(getThreadHandle()); @@ -968,7 +975,11 @@ void Agent::SetParentHandle( std::unique_ptr<ParentInspectorHandle> Agent::GetParentHandle( int thread_id, const std::string& url) { - return client_->getWorkerManager()->NewParentHandle(thread_id, url); + if (!parent_handle_) { + return client_->getWorkerManager()->NewParentHandle(thread_id, url); + } else { + return parent_handle_->NewParentInspectorHandle(thread_id, url); + } } void Agent::WaitForConnect() { |