diff options
author | Aleksei Koziatinskii <ak239spb@gmail.com> | 2019-05-14 18:13:48 -0700 |
---|---|---|
committer | Aleksei Koziatinskii <ak239spb@gmail.com> | 2019-06-02 22:37:11 +0300 |
commit | 7e18c650de419ae98511be3c7bc54b34efc6d3d4 (patch) | |
tree | 2793e5e9ad53c6e55febdb858383307418132fe3 /src/inspector | |
parent | e8f31191902a8304f77f7ed4377f10de91aca103 (diff) | |
download | node-new-7e18c650de419ae98511be3c7bc54b34efc6d3d4.tar.gz |
inspector: supported NodeRuntime domain in worker
NodeRuntime domain was introduced to give inspector client way to
fetch captured information before Node process is gone. We need
similar capability for work.
With current protocol inspector client can force worker to wait
on start by passing waitForDebuggerOnStart flag to NodeWorker.enable
method. So client has some time to setup environment, e.g. start
profiler. At the same time there is no way to prevent worker from
being terminated. So we can start capturing profile but we can not
reliably get captured data back.
This PR implemented NodeRuntime.notifyWhenWaitingForDisconnect
method for worker. When NodeRuntime.waitingForDisconnect notification
is enabled, worker will wait for explicit NodeWorker.detach call.
With this PR worker tooling story is nicely aligned with main thread
tooling story. The only difference is that main thread by default is
waiting for disconnect but worker thread is not waiting.
Issue: https://github.com/nodejs/node/issues/27677
PR-URL: https://github.com/nodejs/node/pull/27706
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Diffstat (limited to 'src/inspector')
-rw-r--r-- | src/inspector/node_protocol.pdl | 5 | ||||
-rw-r--r-- | src/inspector/runtime_agent.cc | 4 | ||||
-rw-r--r-- | src/inspector/worker_agent.cc | 5 | ||||
-rw-r--r-- | src/inspector/worker_agent.h | 1 |
4 files changed, 11 insertions, 4 deletions
diff --git a/src/inspector/node_protocol.pdl b/src/inspector/node_protocol.pdl index 36d528b937..608521b467 100644 --- a/src/inspector/node_protocol.pdl +++ b/src/inspector/node_protocol.pdl @@ -71,6 +71,11 @@ experimental domain NodeWorker # Detaches from all running workers and disables attaching to new workers as they are started. command disable + # Detached from the worker with given sessionId. + command detach + parameters + SessionID sessionId + # Issued when attached to a worker. event attachedToWorker parameters diff --git a/src/inspector/runtime_agent.cc b/src/inspector/runtime_agent.cc index f8fdbe42d4..4056140e70 100644 --- a/src/inspector/runtime_agent.cc +++ b/src/inspector/runtime_agent.cc @@ -16,10 +16,6 @@ void RuntimeAgent::Wire(UberDispatcher* dispatcher) { } DispatchResponse RuntimeAgent::notifyWhenWaitingForDisconnect(bool enabled) { - if (!env_->owns_process_state()) { - return DispatchResponse::Error( - "NodeRuntime domain can only be used through main thread sessions"); - } notify_when_waiting_for_disconnect_ = enabled; return DispatchResponse::OK(); } diff --git a/src/inspector/worker_agent.cc b/src/inspector/worker_agent.cc index d343de8494..81706572e6 100644 --- a/src/inspector/worker_agent.cc +++ b/src/inspector/worker_agent.cc @@ -115,6 +115,11 @@ DispatchResponse WorkerAgent::disable() { return DispatchResponse::OK(); } +DispatchResponse WorkerAgent::detach(const String& sessionId) { + workers_->Detached(sessionId); + return DispatchResponse::OK(); +} + void NodeWorkers::WorkerCreated(const std::string& title, const std::string& url, bool waiting, diff --git a/src/inspector/worker_agent.h b/src/inspector/worker_agent.h index 402c719416..1bd25189bf 100644 --- a/src/inspector/worker_agent.h +++ b/src/inspector/worker_agent.h @@ -25,6 +25,7 @@ class WorkerAgent : public NodeWorker::Backend { DispatchResponse enable(bool waitForDebuggerOnStart) override; DispatchResponse disable() override; + DispatchResponse detach(const String& sessionId) override; private: std::shared_ptr<NodeWorker::Frontend> frontend_; |