Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
islandryu opened this issue Dec 23, 2024 · 0 comments
Open

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

islandryu opened this issue Dec 23, 2024 · 0 comments

Comments

@islandryu
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant