Skip to content

fix(browser): Fix parenthesis parsing logic for chromium #12373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 6, 2024

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Jun 5, 2024

We had a bug where the chrome stack trace parser incorrectly parsed stack frames when the frame was not inside a function (ie. top level in a module) and contained parentheses.

This surfaced in Next.js because Next.js has file based routing with folders that can contain parentheses and our debug ID injection snippet is injected top-level.

We fix this by first using a regex that attempts to match a simple top level module frame, and if it matches we extract the filename and line/colnumbers without attempting to use the more elaborate regex.

@lforst lforst force-pushed the lforst-fix-chromium-paretheses-parse branch from c93fa86 to 1933b22 Compare June 5, 2024 12:27
Copy link
Contributor

github-actions bot commented Jun 5, 2024

size-limit report 📦

Path Size
@sentry/browser 21.78 KB (+0.2% 🔺)
@sentry/browser (incl. Tracing) 32.82 KB (+0.16% 🔺)
@sentry/browser (incl. Tracing, Replay) 68.4 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.69 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.45 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.57 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 86.4 KB (+0.06% 🔺)
@sentry/browser (incl. metrics) 25.96 KB (+0.19% 🔺)
@sentry/browser (incl. Feedback) 37.94 KB (+0.12% 🔺)
@sentry/browser (incl. sendFeedback) 26.37 KB (+0.18% 🔺)
@sentry/browser (incl. FeedbackAsync) 30.92 KB (+0.19% 🔺)
@sentry/react 24.55 KB (+0.2% 🔺)
@sentry/react (incl. Tracing) 35.86 KB (+0.13% 🔺)
@sentry/vue 25.79 KB (+0.23% 🔺)
@sentry/vue (incl. Tracing) 34.66 KB (+0.15% 🔺)
@sentry/svelte 21.91 KB (+0.21% 🔺)
CDN Bundle 23.16 KB (+0.19% 🔺)
CDN Bundle (incl. Tracing) 34.54 KB (+0.12% 🔺)
CDN Bundle (incl. Tracing, Replay) 68.46 KB (+0.05% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 73.64 KB (+0.06% 🔺)
CDN Bundle - uncompressed 68.1 KB (+0.16% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 102.28 KB (+0.11% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 212.17 KB (+0.05% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 224.64 KB (+0.05% 🔺)
@sentry/nextjs (client) 35.21 KB (+0.17% 🔺)
@sentry/sveltekit (client) 33.45 KB (+0.16% 🔺)
@sentry/node 115.24 KB (0%)
@sentry/node - without tracing 94.55 KB (0%)
@sentry/aws-serverless 103.72 KB (0%)

@timfish
Copy link
Collaborator

timfish commented Jun 5, 2024

0.2% bundle increase which busted the size limit for @sentry/browser (incl. Tracing, Replay)

@@ -579,6 +579,7 @@ describe('Tracekit - Chrome Tests', () => {
name: 'Error',
stack: `Error: bad
at something (http://localhost:5000/(some)/(thing)/index.html:20:16)
at http://localhost:5000/(group)/[route]/script.js:1:126
at more (http://localhost:5000/(some)/(thing)/index.html:25:7)`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this could be passed?

at (http://localhost:5000/(group)/[route]/script.js:1:126)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought but chrome doesn't emit such frames I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't seen stack lines like that. They only appear to be surrounded in parenthesis when there is filename.

@lforst lforst marked this pull request as ready for review June 5, 2024 13:22
@lforst lforst changed the title fix(nextjs): Fix parenthesis parsing logic for chromium fix(browser): Fix parenthesis parsing logic for chromium Jun 5, 2024
@@ -51,13 +51,22 @@ function createFrame(filename: string, func: string, lineno?: number, colno?: nu
}

// Chromium based browsers: Chrome, Brave, new Opera, new Edge
const chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a comment here for what this would match, as an example? makes it easier to follow this than to try to parse the regex 😅

@lforst lforst merged commit e45f8a6 into develop Jun 6, 2024
110 checks passed
@lforst lforst deleted the lforst-fix-chromium-paretheses-parse branch June 6, 2024 08:47
@dohooo
Copy link

dohooo commented Jun 6, 2024

nice @lforst when will it be released?

@lforst
Copy link
Contributor Author

lforst commented Jun 6, 2024

soon™

@AbhiPrasad
Copy link
Member

@dohooo released with https://github.com/getsentry/sentry-javascript/releases/tag/8.8.0

@dohooo
Copy link

dohooo commented Jun 7, 2024

@dohooo released with https://github.com/getsentry/sentry-javascript/releases/tag/8.8.0

Thanks for mention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants