Node stack parser splits anonymous frames at ` (` inside the file path (`C:\Program Files (x86)\...`, `My App (beta)/...`)

未关闭 适合新手
#26,202 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

阅读packages/core/src/utils/node-stack-trace.ts并检查FULL_MATCH;报告还指出,浏览器解析器chromeStackLineParser也会进行相同的拆分。使用提供的匿名 V8 帧重现问题,这些帧的文件路径包含 (,并检查两个解析器。完成标准是这些帧保留完整文件名并被解析为匿名帧,同时命名帧仍能正确解析。

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

描述

Bug Node.js Waiting for: Product Owner
Is there an existing issue for this?
How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

11.11.0 (also develop 6c6c040256)

Framework Version

Node.js v26.13.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

/home/me/My App (beta)/index.js:

const { defaultStackParser } = require("@sentry/node");
try {
  [1].forEach(() => {
    throw new Error("boom");
  });
} catch (err) {
  console.log(err.stack.split("\n")[1]);
  const top = defaultStackParser(err.stack).pop();
  console.log(top.filename, "|", top.function, top.lineno, top.colno);
}
Steps to Reproduce

Run node index.js from a directory whose path contains a space followed by (. The same happens for any anonymous V8 frame such as at C:\Program Files (x86)\MyApp\index.js:2:9 or at async /home/me/My App (beta)/index.js:2:9.

Expected Result
    at /home/me/My App (beta)/index.js:4:11
/home/me/My App (beta)/index.js | ? 4 11
Actual Result
    at /home/me/My App (beta)/index.js:4:11
beta)/index.js | /home/me/My App 4 11

Parsing at C:\Program Files (x86)\MyApp\index.js:2:9 returns {"function":"C:\\Program Files","filename":"x86)\\MyApp\\index.js","in_app":false}. Named frames (at main (/home/me/My App (beta)/index.js:5:3)) are parsed as expected.

Additional Context

FULL_MATCH in packages/core/src/utils/node-stack-trace.ts is /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/; the optional lazy (.+?)\s+\( function-name group matches up to the first ( in the path even when the line has no name ( prefix. The truncated filename no longer starts with / or a Windows drive letter, so filenameIsInApp also returns false, and source map lookup and code context fail for these frames. The browser chromeStackLineParser shows the same split for Node-style frames.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Credit: https://ucsbplse.github.io/

主要语言
TypeScript
星标
8.8k
派生
1.9k
平均合并
1 天 21 小时
30 天内合并 PR
637

环境准备

从这里开始

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

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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