Skip to content

inspector: add way to force worker to wait inspector session detach #27677

@alexkozy

Description

@alexkozy

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:

  1. Start process with --inspect-brk flag in this case process will wait for Runtime.runIfWaitingForDebugger call.
  2. Start tool, tool connects to process, prepare everything, e.g. enable profiler using Profiler.start and when ready tool starts process using Runtime.runIfWaitingForDebugger.
  3. When process is finished it sends Runtime.executionContextDestroyed for main context and waits for tool to disconnect.
  4. Tool gets events capture all required data and disconnect.
  5. Node process finished.

In this case we have nice way to get all data and avoid any possible race condition.

For workers right now:

  1. Tool calls NodeWorker.enable with waitForDebuggerOnStart equals true.
  2. When worker is started, it sends NodeWorker.attachedToWorker and waits tool to call Runtime.runIfWaitingForDebugger.
  3. Tool prepare session, e.g. start profiler and send Runtime.runIfWaitingForDebugger
  4. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions