Skip to content

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

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jul 29, 2025

#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.

Copy link
Contributor

github-actions bot commented Jul 29, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.83 kB +0.3% +69 B 🔺
@sentry/browser - with treeshaking flags 22.42 kB +0.34% +75 B 🔺
@sentry/browser (incl. Tracing) 39.51 kB +0.2% +76 B 🔺
@sentry/browser (incl. Tracing, Replay) 77.59 kB +0.1% +72 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.46 kB +0.11% +69 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 82.29 kB +0.09% +73 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 94.43 kB +0.09% +76 B 🔺
@sentry/browser (incl. Feedback) 40.53 kB +0.2% +77 B 🔺
@sentry/browser (incl. sendFeedback) 28.52 kB +0.25% +69 B 🔺
@sentry/browser (incl. FeedbackAsync) 33.41 kB +0.21% +67 B 🔺
@sentry/react 25.56 kB +0.26% +66 B 🔺
@sentry/react (incl. Tracing) 41.47 kB +0.18% +73 B 🔺
@sentry/vue 28.27 kB +0.26% +72 B 🔺
@sentry/vue (incl. Tracing) 41.31 kB +0.2% +80 B 🔺
@sentry/svelte 23.86 kB +0.29% +68 B 🔺
CDN Bundle 25.36 kB +0.3% +75 B 🔺
CDN Bundle (incl. Tracing) 39.38 kB +0.2% +75 B 🔺
CDN Bundle (incl. Tracing, Replay) 75.45 kB +0.09% +67 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 80.89 kB +0.1% +77 B 🔺
CDN Bundle - uncompressed 74.05 kB +0.25% +184 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 116.53 kB +0.16% +184 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 230.75 kB +0.08% +184 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 243.56 kB +0.08% +184 B 🔺
@sentry/nextjs (client) 43.54 kB +0.2% +86 B 🔺
@sentry/sveltekit (client) 39.94 kB +0.19% +74 B 🔺
@sentry/node-core 47.53 kB - -
@sentry/node 146.19 kB - -
@sentry/node - without tracing 91.63 kB - -
@sentry/aws-serverless 103.08 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 Lms24 force-pushed the lms/fix-browser-long-data-urls branch from 9084de1 to e26cd1d Compare August 1, 2025 13:43
@Lms24 Lms24 marked this pull request as ready for review August 1, 2025 13:43
@Lms24 Lms24 requested review from timfish and AbhiPrasad August 1, 2025 13:50
Copy link
Collaborator

@timfish timfish left a comment

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.

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.

2 participants