Skip to content

Commit

Permalink
fix(browser): Support async in stack frame urls (#7131)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Feb 10, 2023
1 parent b49d9f7 commit c3806eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/browser/src/stack-parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function createFrame(filename: string, func: string, lineno?: number, colno?: nu

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

const chrome: StackLineParserFn = line => {
Expand Down
25 changes: 25 additions & 0 deletions packages/browser/test/unit/tracekit/chromium.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,31 @@ describe('Tracekit - Chrome Tests', () => {
});
});

it('should parse frames with async urls', () => {
const CHROME_109_ASYNC_URL = {
message: 'bad',
name: 'Error',
stack: `Error: bad
at callAnotherThing (http://localhost:5000/:20:16)
at Object.callback (async http://localhost:5000/:25:7)
at test (http://localhost:5000/:33:23)`,
};

const ex = exceptionFromError(parser, CHROME_109_ASYNC_URL);

expect(ex).toEqual({
value: 'bad',
type: 'Error',
stacktrace: {
frames: [
{ filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 23, in_app: true },
{ filename: 'http://localhost:5000/', function: 'Object.callback', lineno: 25, colno: 7, in_app: true },
{ filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 16, in_app: true },
],
},
});
});

it('should parse exceptions with native code frames in Edge 44', () => {
const EDGE44_NATIVE_CODE_EXCEPTION = {
message: 'test',
Expand Down

0 comments on commit c3806eb

Please sign in to comment.