Skip to content
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

fix(browser): Don't assume window.document is available #11602

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

lforst
Copy link
Member

@lforst lforst commented Apr 15, 2024

Ref: #5289 (comment)

We cannot assume window.document is available because we support web workers.

Copy link
Contributor

github-actions bot commented Apr 15, 2024

size-limit report 📦

Path Size
@sentry/browser 22.16 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) 31.77 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) 67.08 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 60.5 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.91 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 80.79 KB (+0.02% 🔺)
@sentry/browser (incl. Feedback) 35.71 KB (+0.01% 🔺)
@sentry/browser (incl. Feedback, Feedback Modal) 35.71 KB (+0.01% 🔺)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 37.74 KB (+0.01% 🔺)
@sentry/browser (incl. sendFeedback) 26.95 KB (+0.01% 🔺)
@sentry/react 24.84 KB (+0.01% 🔺)
@sentry/react (incl. Tracing) 34.66 KB (+0.06% 🔺)
@sentry/vue 25.73 KB (+0.01% 🔺)
@sentry/vue (incl. Tracing) 33.48 KB (+0.1% 🔺)
@sentry/svelte 22.29 KB (+0.02% 🔺)
CDN Bundle 24.48 KB (+0.01% 🔺)
CDN Bundle (incl. Tracing) 32.99 KB (+0.07% 🔺)
CDN Bundle (incl. Tracing, Replay) 66.6 KB (+0.03% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 82.81 KB (+0.01% 🔺)
CDN Bundle - uncompressed 72.9 KB (+0.01% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 99.01 KB (+0.12% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 208.67 KB (+0.06% 🔺)
@sentry/nextjs (client) 34.03 KB (+0.06% 🔺)
@sentry/sveltekit (client) 32.26 KB (+0.04% 🔺)
@sentry/node 120.17 KB (+0.01% 🔺)

@lforst lforst requested review from mydea, AbhiPrasad and Lms24 April 15, 2024 12:11
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Good catch! Is there an issue where this came up?

// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
WINDOW.document.addEventListener(type, () => setTimeout(stopListening, 0), true);
Copy link
Member

Choose a reason for hiding this comment

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

l: for bundle size reasons: Is it necessary to explicitly call addEventListener on WINDOW.document if we have the guard above?

@lforst
Copy link
Member Author

lforst commented Apr 15, 2024

Good catch! Is there an issue where this came up?

Yeah this one! #5289 (comment)

@lforst lforst merged commit ee4091e into develop Apr 16, 2024
90 checks passed
@lforst lforst deleted the lforst-no-window-document branch April 16, 2024 12:21
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