worker_threads that use es modules incorrectly pause when loaded
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
- Version: 16.0.0
- Platform: Win 10 x64
- Subsystem: inspector
What steps will reproduce the bug?
It's easiest to run under a debugger that supports worker threads, like VS Code's Node.js debugger. I've created an example repo here:
- Open the folder in VS Code
- In the debug view (play button on the left hand side), select "No Bug" and hit the play button. This runs
no-bug/index.js. - A worker thread spawns, logs its message, and exits
- Now select "Bug", and hit the play button. This runs
bug/index.js: the same code in an ES module. - The debugger pauses on the first line in the worker
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
The debugger doesn't pause with ES modules
What do you see instead?
The debugger pauses
Additional information
It looks like Node.js is incorrectly reporting that the program is started with inspectBrk:

VS Code (and Webstorm I think, though I haven't tried to repro there) use a bootloader to inject ourselves into the process via NODE_OPTIONS. We don't actually invoke with --inspect-brk, we manually call inspector.waitForDebugger(). I'm guessing this triggers inspectBrk to be true, but I haven't debugged into it that far.
This was originally reported in https://github.com/microsoft/vscode/issues/122170
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con bug/index.js e no-bug/index.js usando il debugger Node.js di VS Code. Inizia confrontando il comportamento dei worker ES-module e non-module in relazione alla chiamata inspector.waitForDebugger() e al VS Code bootloader collegato. Il lavoro è completato quando il debugger non si ferma più sulla prima riga del worker nel caso ES-module.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, nodejs
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100