Skip to content

--inspect-brk causes code with workers to hang #56343

@islandryu

Description

@islandryu

Version

v23.4.0

Platform

Darwin shimaryuuheinoMac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:12 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6020 arm64

Subsystem

No response

What steps will reproduce the bug?

Run this code with --inspect-brk and inspect it using Chrome DevTools.

const { Worker } = require('worker_threads');

const worker = new Worker('console.log("Worker thread is running")', { eval: true });

console.log('Main thread is running');

process.on('exit', () => {
  console.log('Main thread is exiting');
});
worker.on('exit', (message) => {
  process.exit(); 
});

How often does it reproduce? Is there a required condition?

constantly

What is the expected behavior? Why is that the expected behavior?

Debugger listening on ws://127.0.0.1:9229/a33bf964-bb8c-432a-9d6b-191d26bef40a
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Main thread is running
Worker thread is running
Main thread is exiting
Waiting for the debugger to disconnect...

What do you see instead?

The worker does not execute and stops

Debugger listening on ws://127.0.0.1:9229/a301d300-fc77-40c7-b5a2-03042079e8b0
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Main thread is running

Additional information

It seems that the parent thread's --inspect-brk setting is inherited.

https://nodejs.org/api/worker_threads.html#new-workerfilename-options
According to the documentation, the child threads inherit the parent thread's options by default, so this might be a feature request rather than a bug report.
However, it was working as expected in at least version 22.1.0.

In any case, I want to be able to run --inspect-brk without needing to add additional options to the worker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inspectorIssues and PRs related to the V8 inspector protocolworkerIssues and PRs related to Worker support.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions