Skip to content

Commit

Permalink
Always return 0-based columns from parseErrorStack
Browse files Browse the repository at this point in the history
Summary:
Fixes a bug where we were skewing some stack traces by sending 1-based column numbers to the Metro symbolication endpoint, which expects them to be 0-based. This is achieved by subtracting 1 from the column numbers we find in textual stack traces, which are almost universally 1-based in current JS engines.

The bug is only noticeable in *some* cases, namely where the column immediately following the correct one is in a different function.

NOTE: The behaviour under Hermes was fixed separately, in a previous commit. This fix applies to other engines (e.g. JSC).

Changelog: [General] [Fixed] - Fix stack traces showing the wrong function name in some cases

Reviewed By: cpojer

Differential Revision: D18628230

fbshipit-source-id: 5677803500e45a41c1005496d19c150526af2d07
  • Loading branch information
motiz88 authored and facebook-github-bot committed Dec 2, 2019
1 parent 75d03b5 commit 60b4ba1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Core/Devtools/parseErrorStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ function parseErrorStack(e: ExtendedError): Array<StackFrame> {
? e.stack
: global.HermesInternal
? convertHermesStack(parseHermesStack(e.stack))
: stacktraceParser.parse(e.stack);
: stacktraceParser.parse(e.stack).map(frame => ({
...frame,
column: frame.column != null ? frame.column - 1 : null,
}));

return stack;
}
Expand Down

0 comments on commit 60b4ba1

Please sign in to comment.