-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Description
Is your feature request related to a problem? Please describe.
I am working on a tool that exposes different information available over the inspector protocol from Node (https://github.com/ak239/thetool). Right now I can get the data from processes and I would like to add way to get this data from workers as well.
With regular process following way to get all information is available:
- Start process with --inspect-brk flag in this case process will wait for
Runtime.runIfWaitingForDebugger
call. - Start tool, tool connects to process, prepare everything, e.g. enable profiler using
Profiler.start
and when ready tool starts process usingRuntime.runIfWaitingForDebugger
. - When process is finished it sends
Runtime.executionContextDestroyed
for main context and waits for tool to disconnect. - Tool gets events capture all required data and disconnect.
- Node process finished.
In this case we have nice way to get all data and avoid any possible race condition.
For workers right now:
- Tool calls
NodeWorker.enable
withwaitForDebuggerOnStart
equals true. - When worker is started, it sends
NodeWorker.attachedToWorker
and waits tool to callRuntime.runIfWaitingForDebugger
. - Tool prepare session, e.g. start profiler and send
Runtime.runIfWaitingForDebugger
- Worker sends
NodeWorker.detachedFromWorker
. When tool gets this event it is too late to try to get any data from worker session. It is gone.
Describe the solution you'd like
Based on @eugeneo comment:
Implement NodeRuntime
in worker. NodeRuntime. notifyWhenWaitingForDisconnect
will force Worker to wait for disconnect and worker will send NodeRuntime. waitingForDisconnect
when it is done. NodeWorker domain should get NodeWorker.detach
to make disconnect possible.
@eugeneo what do you think?