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

Open Beginner friendly
#26,202 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Read packages/core/src/utils/node-stack-trace.ts and inspect FULL_MATCH; the report also says the browser chromeStackLineParser has the same split. Reproduce with the supplied anonymous V8 frames whose file paths contain ( and check both parsers. Done when these frames retain the full filename and are parsed as anonymous frames, while named frames still parse correctly.

Written by the indexing model from the issue text.

Description

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/

Dominant language
TypeScript
Stars
8.8k
Forks
1.9k
Avg merge
1d 21h
Merged PRs (30d)
637

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-javascript

All issues in getsentry/sentry-javascript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.