• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const { Session } = require('inspector');
2const { parentPort } = require('worker_threads');
3
4const session = new Session();
5
6parentPort.once('message', () => {}); // Prevent the worker from exiting.
7
8session.connectToMainThread();
9
10session.on(
11  'NodeWorker.attachedToWorker',
12  ({ params: { workerInfo } }) => {
13    // send the worker title to the main thread
14    parentPort.postMessage(workerInfo.title);
15  }
16);
17session.post('NodeWorker.enable', { waitForDebuggerOnStart: false });
18