Skip to content

Commit c3806eb

Browse files
authored
fix(browser): Support async in stack frame urls (#7131)
1 parent b49d9f7 commit c3806eb

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/browser/src/stack-parsers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function createFrame(filename: string, func: string, lineno?: number, colno?: nu
3131

3232
// Chromium based browsers: Chrome, Brave, new Opera, new Edge
3333
const chromeRegex =
34-
/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
34+
/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?(?:async )?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
3535
const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
3636

3737
const chrome: StackLineParserFn = line => {

packages/browser/test/unit/tracekit/chromium.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,31 @@ describe('Tracekit - Chrome Tests', () => {
332332
});
333333
});
334334

335+
it('should parse frames with async urls', () => {
336+
const CHROME_109_ASYNC_URL = {
337+
message: 'bad',
338+
name: 'Error',
339+
stack: `Error: bad
340+
at callAnotherThing (http://localhost:5000/:20:16)
341+
at Object.callback (async http://localhost:5000/:25:7)
342+
at test (http://localhost:5000/:33:23)`,
343+
};
344+
345+
const ex = exceptionFromError(parser, CHROME_109_ASYNC_URL);
346+
347+
expect(ex).toEqual({
348+
value: 'bad',
349+
type: 'Error',
350+
stacktrace: {
351+
frames: [
352+
{ filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 23, in_app: true },
353+
{ filename: 'http://localhost:5000/', function: 'Object.callback', lineno: 25, colno: 7, in_app: true },
354+
{ filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 16, in_app: true },
355+
],
356+
},
357+
});
358+
});
359+
335360
it('should parse exceptions with native code frames in Edge 44', () => {
336361
const EDGE44_NATIVE_CODE_EXCEPTION = {
337362
message: 'test',

0 commit comments

Comments
 (0)