diff options
Diffstat (limited to 'src')
-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 | ||||
-rw-r--r-- | src/inspector_agent.cc | 18 |
5 files changed, 23 insertions, 10 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_; diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 12e62d3e2b..09593297e0 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -472,8 +472,8 @@ class NodeInspectorClient : public V8InspectorClient { runMessageLoop(); } - void waitForIoShutdown() { - waiting_for_io_shutdown_ = true; + void waitForSessionsDisconnect() { + waiting_for_sessions_disconnect_ = true; runMessageLoop(); } @@ -548,6 +548,8 @@ class NodeInspectorClient : public V8InspectorClient { } contextDestroyed(env_->context()); } + if (waiting_for_sessions_disconnect_ && !is_main_) + waiting_for_sessions_disconnect_ = false; } void dispatchMessageFromFrontend(int session_id, const StringView& message) { @@ -678,8 +680,9 @@ class NodeInspectorClient : public V8InspectorClient { bool shouldRunMessageLoop() { if (waiting_for_frontend_) return true; - if (waiting_for_io_shutdown_ || waiting_for_resume_) + if (waiting_for_sessions_disconnect_ || waiting_for_resume_) { return hasConnectedSessions(); + } return false; } @@ -723,7 +726,7 @@ class NodeInspectorClient : public V8InspectorClient { int next_session_id_ = 1; bool waiting_for_resume_ = false; bool waiting_for_frontend_ = false; - bool waiting_for_io_shutdown_ = false; + bool waiting_for_sessions_disconnect_ = false; // Allows accessing Inspector from non-main threads std::unique_ptr<MainThreadInterface> interface_; std::shared_ptr<WorkerManager> worker_manager_; @@ -819,11 +822,14 @@ void Agent::WaitForDisconnect() { fprintf(stderr, "Waiting for the debugger to disconnect...\n"); fflush(stderr); } - if (!client_->notifyWaitingForDisconnect()) + if (!client_->notifyWaitingForDisconnect()) { client_->contextDestroyed(parent_env_->context()); + } else if (is_worker) { + client_->waitForSessionsDisconnect(); + } if (io_ != nullptr) { io_->StopAcceptingNewConnections(); - client_->waitForIoShutdown(); + client_->waitForSessionsDisconnect(); } } |