Skip to content

fix(browser): Handle data urls in errors caught by globalHandlersIntegration - #17216

Merged
Lms24 merged 4 commits into
developfrom
lms/fix-browser-long-data-urls
Aug 7, 2025
Merged

fix(browser): Handle data urls in errors caught by globalHandlersIntegration#17216
Lms24 merged 4 commits into
developfrom
lms/fix-browser-long-data-urls

Conversation

@Lms24

@Lms24Lms24 commented Jul 29, 2025

Copy link
Copy Markdown
Member

#17218 adjusted data URI stack line parsing for most errors that go through the stack parsers (fully for node, line truncation in general). This PR now applies a similar logic to globalHandlersIntegration which in some conditions applies a stack frame that doesn't go through the same stack parser.

@github-actions

github-actionsBot commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser24.11 kB+0.3%+72 B 🔺
@sentry/browser - with treeshaking flags22.68 kB+0.3%+67 B 🔺
@sentry/browser (incl. Tracing)39.82 kB+0.19%+75 B 🔺
@sentry/browser (incl. Tracing, Replay)77.92 kB+0.09%+64 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags67.77 kB+0.11%+73 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)82.62 kB+0.08%+66 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)94.73 kB+0.07%+64 B 🔺
@sentry/browser (incl. Feedback)40.77 kB+0.19%+74 B 🔺
@sentry/browser (incl. sendFeedback)28.77 kB+0.25%+70 B 🔺
@sentry/browser (incl. FeedbackAsync)33.66 kB+0.2%+65 B 🔺
@sentry/react25.83 kB+0.27%+67 B 🔺
@sentry/react (incl. Tracing)41.77 kB+0.19%+77 B 🔺
@sentry/vue28.59 kB+0.29%+81 B 🔺
@sentry/vue (incl. Tracing)41.64 kB+0.18%+73 B 🔺
@sentry/svelte24.14 kB+0.3%+71 B 🔺
CDN Bundle25.62 kB+0.28%+71 B 🔺
CDN Bundle (incl. Tracing)39.71 kB+0.19%+73 B 🔺
CDN Bundle (incl. Tracing, Replay)75.76 kB+0.09%+62 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)81.18 kB+0.1%+74 B 🔺
CDN Bundle - uncompressed74.89 kB+0.25%+184 B 🔺
CDN Bundle (incl. Tracing) - uncompressed117.5 kB+0.16%+184 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed231.77 kB+0.08%+184 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed244.37 kB+0.08%+184 B 🔺
@sentry/nextjs (client)43.83 kB+0.19%+82 B 🔺
@sentry/sveltekit (client)40.27 kB+0.18%+70 B 🔺
@sentry/node-core47.73 kB--
@sentry/node146.62 kB--
@sentry/node - without tracing91.83 kB--
@sentry/aws-serverless103.27 kB--

View base workflow run

AbhiPrasad pushed a commit that referenced this pull request Jul 31, 2025
- Ref #17216
Because JavaScript can dynamically load code from text like this:
```ts
const {dynamicFn} = await import(`data:application/javascript,
export function dynamicFn() {
throw new Error('Error from data-uri module');
};`);
dynamicFn();
```
You can get slack lines like this:
```
at dynamicFn (data:application/javascript,export function dynamicFn() { throw new Error('Error from data-uri module');};:1:38)
```
These can be huge, often base64 encoded strings.
Currently we skip regex parsing on anything over 1k in length but that
means we ignore the frame entirely.
This PR:
- Changes the stack parser so that if the line is over 1k, we still pass
the first 1k for parsing
- Adds initial check to the Node line parser that special cases
truncated lines with data URIs in them
@Lms24
Lms24force-pushed the lms/fix-browser-long-data-urls branch from 9084de1 to e26cd1dCompareAugust 1, 2025 13:43
@Lms24
Lms24 marked this pull request as ready for review August 1, 2025 13:43
cursor[bot]

This comment was marked as outdated.

@Lms24
Lms24 requested review from AbhiPrasad and timfishAugust 1, 2025 13:50

@timfishtimfish left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Needs a test!

I've got another PR incoming that adds the data Uri handling to chrome too.

@Lms24
Lms24 requested a review from timfishAugust 7, 2025 11:29
@Lms24

Lms24 commented Aug 7, 2025

Copy link
Copy Markdown
MemberAuthor

good call with the Test, thanks! Added an integration test

@Lms24
Lms24force-pushed the lms/fix-browser-long-data-urls branch from e26cd1d to 22ce8dcCompareAugust 7, 2025 11:31
@Lms24
Lms24 enabled auto-merge (squash) August 7, 2025 11:33
Sign up for freeto 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.

2 participants

@Lms24@timfish