Skip to content

Commit

Permalink
fix(browser): Parse Chrome stack frames without full paths (#5519)
Browse files Browse the repository at this point in the history
Update chromium parser to use extended lazy lookups to account for frames that don't have full path names. Validated through a unit test and by analyzing an error on the Sentry frontend.
  • Loading branch information
timfish committed Aug 3, 2022
1 parent f0ab0e0 commit 474a0a0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/browser/src/stack-parsers.ts
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 )?)?((?: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
67 changes: 67 additions & 0 deletions packages/browser/test/unit/tracekit/chromium.test.ts
Expand Up @@ -430,4 +430,71 @@ describe('Tracekit - Chrome Tests', () => {
},
});
});

it('should parse exceptions with frames without full paths', () => {
const EXCEPTION = {
message: 'aha',
name: 'Error',
stack: `Error
at Client.requestPromise (api.tsx:554:1)
at doDiscoverQuery (genericDiscoverQuery.tsx?33f8:328:1)
at _GenericDiscoverQuery.eval [as fetchData] (genericDiscoverQuery.tsx?33f8:256:1)
at _GenericDiscoverQuery.componentDidMount (genericDiscoverQuery.tsx?33f8:152:1)
at commitLifeCycles (react-dom.development.js?f8c1:20663:1)
at commitLayoutEffects (react-dom.development.js?f8c1:23426:1)`,
};

const ex = exceptionFromError(parser, EXCEPTION);

expect(ex).toEqual({
value: 'aha',
type: 'Error',
stacktrace: {
frames: [
{
filename: 'react-dom.development.js?f8c1',
function: 'commitLayoutEffects',
in_app: true,
lineno: 23426,
colno: 1,
},
{
filename: 'react-dom.development.js?f8c1',
function: 'commitLifeCycles',
in_app: true,
lineno: 20663,
colno: 1,
},
{
filename: 'genericDiscoverQuery.tsx?33f8',
function: '_GenericDiscoverQuery.componentDidMount',
in_app: true,
lineno: 152,
colno: 1,
},
{
filename: 'genericDiscoverQuery.tsx?33f8',
function: '_GenericDiscoverQuery.eval [as fetchData]',
in_app: true,
lineno: 256,
colno: 1,
},
{
filename: 'genericDiscoverQuery.tsx?33f8',
function: 'doDiscoverQuery',
in_app: true,
lineno: 328,
colno: 1,
},
{
filename: 'api.tsx',
function: 'Client.requestPromise',
in_app: true,
lineno: 554,
colno: 1,
},
],
},
});
});
});

0 comments on commit 474a0a0

Please sign in to comment.