mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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>
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#ifndef SRC_INSPECTOR_WORKER_AGENT_H_
|
|
#define SRC_INSPECTOR_WORKER_AGENT_H_
|
|
|
|
#include "node/inspector/protocol/NodeWorker.h"
|
|
#include "v8.h"
|
|
|
|
|
|
namespace node {
|
|
namespace inspector {
|
|
class WorkerManagerEventHandle;
|
|
class WorkerManager;
|
|
|
|
namespace protocol {
|
|
class NodeWorkers;
|
|
|
|
class WorkerAgent : public NodeWorker::Backend {
|
|
public:
|
|
explicit WorkerAgent(std::weak_ptr<WorkerManager> manager);
|
|
~WorkerAgent() override = default;
|
|
|
|
void Wire(UberDispatcher* dispatcher);
|
|
|
|
DispatchResponse sendMessageToWorker(const String& message,
|
|
const String& sessionId) override;
|
|
|
|
DispatchResponse enable(bool waitForDebuggerOnStart) override;
|
|
DispatchResponse disable() override;
|
|
DispatchResponse detach(const String& sessionId) override;
|
|
|
|
private:
|
|
std::shared_ptr<NodeWorker::Frontend> frontend_;
|
|
std::weak_ptr<WorkerManager> manager_;
|
|
std::unique_ptr<WorkerManagerEventHandle> event_handle_;
|
|
std::shared_ptr<NodeWorkers> workers_;
|
|
};
|
|
} // namespace protocol
|
|
} // namespace inspector
|
|
} // namespace node
|
|
|
|
#endif // SRC_INSPECTOR_WORKER_AGENT_H_
|