|
2 | 2 |
|
3 | 3 | #include "inspector/main_thread_interface.h" |
4 | 4 | #include "inspector/node_string.h" |
| 5 | +#include "inspector/runtime_agent.h" |
5 | 6 | #include "inspector/tracing_agent.h" |
6 | 7 | #include "inspector/worker_agent.h" |
7 | 8 | #include "inspector/worker_inspector.h" |
@@ -228,13 +229,17 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, |
228 | 229 | tracing_agent_->Wire(node_dispatcher_.get()); |
229 | 230 | worker_agent_ = std::make_unique<protocol::WorkerAgent>(worker_manager); |
230 | 231 | worker_agent_->Wire(node_dispatcher_.get()); |
| 232 | + runtime_agent_.reset(new protocol::RuntimeAgent(env)); |
| 233 | + runtime_agent_->Wire(node_dispatcher_.get()); |
231 | 234 | } |
232 | 235 |
|
233 | 236 | ~ChannelImpl() override { |
234 | 237 | tracing_agent_->disable(); |
235 | 238 | tracing_agent_.reset(); // Dispose before the dispatchers |
236 | 239 | worker_agent_->disable(); |
237 | 240 | worker_agent_.reset(); // Dispose before the dispatchers |
| 241 | + runtime_agent_->disable(); |
| 242 | + runtime_agent_.reset(); // Dispose before the dispatchers |
238 | 243 | } |
239 | 244 |
|
240 | 245 | std::string dispatchProtocolMessage(const StringView& message) { |
@@ -264,6 +269,10 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, |
264 | 269 | return prevent_shutdown_; |
265 | 270 | } |
266 | 271 |
|
| 272 | + bool reportWaitingForDebuggerToDisconnect() { |
| 273 | + return runtime_agent_->reportWaitingForDebuggerToDisconnect(); |
| 274 | + } |
| 275 | + |
267 | 276 | private: |
268 | 277 | void sendResponse( |
269 | 278 | int callId, |
@@ -303,6 +312,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, |
303 | 312 | DCHECK(false); |
304 | 313 | } |
305 | 314 |
|
| 315 | + std::unique_ptr<protocol::RuntimeAgent> runtime_agent_; |
306 | 316 | std::unique_ptr<protocol::TracingAgent> tracing_agent_; |
307 | 317 | std::unique_ptr<protocol::WorkerAgent> worker_agent_; |
308 | 318 | std::unique_ptr<InspectorSessionDelegate> delegate_; |
@@ -610,6 +620,14 @@ class NodeInspectorClient : public V8InspectorClient { |
610 | 620 | return false; |
611 | 621 | } |
612 | 622 |
|
| 623 | + bool reportWaitingForDebuggerToDisconnect() { |
| 624 | + for (const auto& id_channel : channels_) { |
| 625 | + if (id_channel.second->reportWaitingForDebuggerToDisconnect()) |
| 626 | + return true; |
| 627 | + } |
| 628 | + return false; |
| 629 | + } |
| 630 | + |
613 | 631 | std::shared_ptr<MainThreadHandle> getThreadHandle() { |
614 | 632 | if (interface_ == nullptr) { |
615 | 633 | interface_.reset(new MainThreadInterface( |
@@ -779,7 +797,8 @@ void Agent::WaitForDisconnect() { |
779 | 797 | } |
780 | 798 | // TODO(addaleax): Maybe this should use an at-exit hook for the Environment |
781 | 799 | // or something similar? |
782 | | - client_->contextDestroyed(parent_env_->context()); |
| 800 | + if (!client_->reportWaitingForDebuggerToDisconnect()) |
| 801 | + client_->contextDestroyed(parent_env_->context()); |
783 | 802 | if (io_ != nullptr) { |
784 | 803 | io_->StopAcceptingNewConnections(); |
785 | 804 | client_->waitForIoShutdown(); |
|
0 commit comments