Skip to content

fix: parse anonymous frame paths with parens and strip async prefix - #77

Open
chiragbitoni wants to merge 1 commit into
tapjs:mainfrom
chiragbitoni:fix/parse-anonymous-frame-paths-and-async
Open

chiragbitoni wants to merge 1 commit into
tapjs:mainfrom
chiragbitoni:fix/parse-anonymous-frame-paths-and-async

Conversation

@chiragbitoni

Copy link
Copy Markdown

Summary

In StackUtils.prototype.parseLine:

  1. When an anonymous frame's path contains ( (such as at /home/me/My App (beta)/index.js:4:11 or at C:\\Program Files (x86)\\app\\index.js:4:11), the regex group (?:(.*?) \()? matched the path prefix before ( as a function name because (\)?)$' allowed an empty string when no closing ) was present. In V8, call locations are only enclosed in parentheses if preceded by a function name, so when no closing parenthesis is present at the end of the line, the frame is anonymous and any ( is part of the file path.
  2. In V8 asynchronous stack frames, V8 prefixes the call site with async (e.g. at async /home/me/app/index.js:4:11 or at async foo (/home/me/app/index.js:4:11)). Previously, async was kept in file for anonymous async frames. Adding (?:async )? strips this marker so file receives the clean file path and named async frames extract the clean function name matching CallSite#getFunctionName().

Fixes #76.

Changes

  • Updated re in index.js to strip leading (?:async )?.
  • In parseLine, recombined fname and file when !closeParen && fname occurs (retaining the full path and leaving function undefined).
  • Added unit tests in test/test.js covering anonymous paths with parens, Windows paths with (x86), and async anonymous & named frames.
  • 100% test coverage maintained across statements, branches, functions, and lines.

Fix parseLine incorrectly treating paths containing ' (' as function
names in anonymous stack frames that lack closing parentheses. Also
strip leading 'async ' from anonymous and named async frames.

Fixes tapjs#76.

Signed-off-by: Chirag Bitoni <chiragbitoni4994@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseLine mis-splits anonymous frames whose path contains (, and keeps async in the file name

1 participant