diff --git a/Libraries/Core/Devtools/__tests__/__snapshots__/parseHermesStack-test.js.snap b/Libraries/Core/Devtools/__tests__/__snapshots__/parseHermesStack-test.js.snap index c3ff6f79a652a5..99798d8b6132b4 100644 --- a/Libraries/Core/Devtools/__tests__/__snapshots__/parseHermesStack-test.js.snap +++ b/Libraries/Core/Devtools/__tests__/__snapshots__/parseHermesStack-test.js.snap @@ -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", +} +`; diff --git a/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js b/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js index 3a299df8f47785..8b24b97294659a 100644 --- a/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js +++ b/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js @@ -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( diff --git a/Libraries/Core/Devtools/parseHermesStack.js b/Libraries/Core/Devtools/parseHermesStack.js index 9d3ba2f9284f2f..70d47a0991d538 100644 --- a/Libraries/Core/Devtools/parseHermesStack.js +++ b/Libraries/Core/Devtools/parseHermesStack.js @@ -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