Skip to content

Commit e539e7d

Browse files
MartinSherburnfacebook-github-bot
authored andcommitted
Fix bug in parseHermesStack.js
Summary: If function name is an empty string then it would fail to parse the line. And not only that, it would cause the entire stack to be lost. This fixes the issue by replacing `.+?` with `.*?`. For example this line fails to parse: ``` at global (:2:4) ``` Changelog: [General][Fixed] - Fixed bug parsing hermes call stacks when the file name is empty Reviewed By: yungsters Differential Revision: D29063192 fbshipit-source-id: 604e457af51f852fe547e6424283631ae148897d
1 parent e24b55e commit e539e7d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

Libraries/Core/Devtools/__tests__/__snapshots__/parseHermesStack-test.js.snap

+28
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,31 @@ Object {
107107
"message": "TypeError: undefined is not a function",
108108
}
109109
`;
110+
111+
exports[`parseHermesStack tolerate empty filename 1`] = `
112+
Object {
113+
"entries": Array [
114+
Object {
115+
"functionName": "global",
116+
"location": Object {
117+
"column1Based": 9,
118+
"line1Based": 1,
119+
"sourceUrl": "unknown",
120+
"type": "SOURCE",
121+
},
122+
"type": "FRAME",
123+
},
124+
Object {
125+
"functionName": "foo$bar",
126+
"location": Object {
127+
"column1Based": 1234,
128+
"line1Based": 10,
129+
"sourceUrl": "",
130+
"type": "SOURCE",
131+
},
132+
"type": "FRAME",
133+
},
134+
],
135+
"message": "TypeError: undefined is not a function",
136+
}
137+
`;

Libraries/Core/Devtools/__tests__/parseHermesStack-test.js

+12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ describe('parseHermesStack', () => {
3838
).toMatchSnapshot();
3939
});
4040

41+
test('tolerate empty filename', () => {
42+
expect(
43+
parseHermesStack(
44+
[
45+
'TypeError: undefined is not a function',
46+
' at global (unknown:1:9)',
47+
' at foo$bar (:10:1234)',
48+
].join('\n'),
49+
),
50+
).toMatchSnapshot();
51+
});
52+
4153
test('skipped frames', () => {
4254
expect(
4355
parseHermesStack(

Libraries/Core/Devtools/parseHermesStack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export type HermesParsedStack = {|
5858
// 4. source URL (filename)
5959
// 5. line number (1 based)
6060
// 6. column number (1 based) or virtual offset (0 based)
61-
const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.+?):(\d+):(\d+)\))$/;
61+
const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/;
6262

6363
// Capturing groups:
6464
// 1. count of skipped frames

0 commit comments

Comments
 (0)