nodejs / nodejs/node

Pause on uncaught exceptions stops at wrong position with ES modules

未关闭
#38,439 8 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

esm inspector
主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

  • Version: 16.0.0
  • Platform: Win 10 x64
  • Subsystem: inspector
What steps will reproduce the bug?

Here's a repo with an easy reproduction:

  1. Open the repo in VS Code (or you can use another tool/any debugger)
  2. In the debug view (play button on the left hand side):
    • Check the [x] Uncaught Exceptions box in the breakpoints view.
    • Select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. The debugger pauses at the location of the throw
  4. Now select "Repro Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses inside internal Node.js module code:

Under the hood this is just calling Debugger.setPauseOnExceptions({ state: 'uncaught' }), so it should be reproducable with any tool. In both cases this leads to a Debugger.pause, with the latter in the wrong location.

I'm guessing there's some inspector ✨magic that happens with commonjs that isn't happening for ES modules.

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

100%

What is the expected behavior?

In both cases, the debugger should pause on the throw

What do you see instead?

In ES modules, it pauses in module_job.js.

Additional information

This was originally reported in https://github.com/microsoft/vscode/issues/122246

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用调试器的未捕获异常设置,在链接的 node-38439 仓库中重现该问题,并比较 no-bug/index.js 与 bug/index.js。阅读 module_job.js 周围的暂停处理逻辑以及 inspector 的入口点;完成的标准是 ES 模块在 throw 所在位置暂停,而不是在内部模块代码中暂停。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, nodejs
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。