mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e24b55ef4f
commit
e539e7d0be
@@ -107,3 +107,31 @@ Object {
|
||||
"message": "TypeError: undefined is not a function",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`parseHermesStack tolerate empty filename 1`] = `
|
||||
Object {
|
||||
"entries": Array [
|
||||
Object {
|
||||
"functionName": "global",
|
||||
"location": Object {
|
||||
"column1Based": 9,
|
||||
"line1Based": 1,
|
||||
"sourceUrl": "unknown",
|
||||
"type": "SOURCE",
|
||||
},
|
||||
"type": "FRAME",
|
||||
},
|
||||
Object {
|
||||
"functionName": "foo$bar",
|
||||
"location": Object {
|
||||
"column1Based": 1234,
|
||||
"line1Based": 10,
|
||||
"sourceUrl": "",
|
||||
"type": "SOURCE",
|
||||
},
|
||||
"type": "FRAME",
|
||||
},
|
||||
],
|
||||
"message": "TypeError: undefined is not a function",
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -38,6 +38,18 @@ describe('parseHermesStack', () => {
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('tolerate empty filename', () => {
|
||||
expect(
|
||||
parseHermesStack(
|
||||
[
|
||||
'TypeError: undefined is not a function',
|
||||
' at global (unknown:1:9)',
|
||||
' at foo$bar (:10:1234)',
|
||||
].join('\n'),
|
||||
),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('skipped frames', () => {
|
||||
expect(
|
||||
parseHermesStack(
|
||||
|
||||
@@ -58,7 +58,7 @@ export type HermesParsedStack = {|
|
||||
// 4. source URL (filename)
|
||||
// 5. line number (1 based)
|
||||
// 6. column number (1 based) or virtual offset (0 based)
|
||||
const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.+?):(\d+):(\d+)\))$/;
|
||||
const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/;
|
||||
|
||||
// Capturing groups:
|
||||
// 1. count of skipped frames
|
||||
|
||||
Reference in New Issue
Block a user