8000 fix(nextjs): Handle braces in stack frame URLs (#7900) · benjick/sentry-javascript@55b51ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 55b51ef

Browse files
authored
fix(nextjs): Handle braces in stack frame URLs (getsentry#7900)
1 parent 63d1937 commit 55b51ef

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/browser/src/stack-parsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function createFrame(filename: string, func: string, lineno?: number, colno?: nu
5555

5656
// Chromium based browsers: Chrome, Brave, new Opera, new Edge
5757
const chromeRegex =
58-
/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
58+
/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
5959
const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
6060

6161
const chrome: StackLineParserFn = line => {

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,41 @@ describe('Tracekit - Chrome Tests', () => {
573573
});
574574
});
575575

576+
it('handles braces in urls', () => {
577+
const CHROME_BRACES_URL = {
578+
message: 'bad',
579+
name: 'Error',
580+
stack: `Error: bad
581+
at something (http://localhost:5000/(some)/(thing)/index.html:20:16)
582+
at more (http://localhost:5000/(some)/(thing)/index.html:25:7)`,
583+
};
584+
585+
const ex = exceptionFromError(parser, CHROME_BRACES_URL);
586+
587+
expect(ex).toEqual({
588+
value: 'bad',
589+
type: 'Error',
590+
stacktrace: {
591+
frames: [
592+
{
593+
filename: 'http://localhost:5000/(some)/(thing)/index.html',
594+
function: 'more',
595+
lineno: 25,
596+
colno: 7,
597+
in_app: true,
598+
},
599+
{
600+
filename: 'http://localhost:5000/(some)/(thing)/index.html',
601+
function: 'something',
602+
lineno: 20,
603+
colno: 16,
604+
in_app: true,
605+
},
606+
],
607+
},
608+
});
609+
});
610+
576611
it('should drop frames that are over 1kb', () => {
577612
const LONG_STR = 'A'.repeat(1040);
578613

0 commit comments

Comments
 (0)
0