nodejs / nodejs/node

worker_threads that use es modules incorrectly pause when loaded

Abierto
#38,420 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

esm inspector worker
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

  • 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:

  1. Open the folder in VS Code
  2. 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.
  3. A worker thread spawns, logs its message, and exits
  4. Now select "Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el problema con bug/index.js y no-bug/index.js usando el depurador de Node.js de VS Code. Empieza comparando el comportamiento de los workers ES-module y non-module en torno a la llamada inspector.waitForDebugger() y al VS Code bootloader asociado. Se considera terminado cuando el depurador ya no se detiene en la primera línea del worker en el caso ES-module.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, nodejs
Área
devtools
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.