fix: replace sentry cdn script injection with bundled package initialization in HyperLoader#1600
fix: replace sentry cdn script injection with bundled package initialization in HyperLoader#1600aritro2002 wants to merge 2 commits into
Conversation
…ization in HyperLoader
🚫 Missing Linked IssueHi 👋 This pull request does not appear to be linked to any open issue yet. Linking your PR to an issue helps keep the project tidy and ensures the issue is closed automatically. ✔️ How to fix this
Once linked, this check will pass automatically on your next push or when you re-run the workflow. Thanks for helping maintainers! 🙌 |
XyneSpaces
left a comment
There was a problem hiding this comment.
Automated PR review completed. No issues found.
XyneSpaces
left a comment
There was a problem hiding this comment.
💡 Sentry initialization now properly uses bundled package
Removing the CDN script injection and using the bundled @sentry/browser package directly is the correct fix for CSP violations in the fullscreen iframe context.
Verification: The change from dynamic script injection to direct Sentry.initiateSentryJs() call eliminates the external network request that was triggering CSP blocks. The typeof !== #undefined guard ensures we don't attempt initialization when Sentry is not configured.
One consideration: Ensure that the GlobalVars.sentryDSN value is properly sanitized/validated before being passed to initiateSentryJs, though this appears to be handled elsewhere in the codebase.
Type of Change
Description
Fixes a CSP violation that occurred when the Google Pay fullscreen iframe attempted to inject the Sentry CDN script.
Problem:
When the Google Pay button was clicked, a fullscreen iframe was mounted loading
fullscreenIndex.html. This iframe includes theHyperLoaderchunk (Hyper.bs.js), which at module load time attempted to dynamically inject an external<script>tag pointing to the Sentry CDN URL (https://js-de.sentry-cdn.com/...). SincefullscreenIndex.htmlhas a strict SDK-controlled CSP meta tag and the Sentry CDN domain was not inauthorizedScriptSources, the browser blocked the script with:Loading the script 'https://js-de.sentry-cdn.com/...' violates the following Content Security Policy directive: "script-src ..."
Root Cause Analysis:
The CDN injection in
Hyper.reswas always redundant. Itsonloadcallback calledSentry.initiateSentryJswhich itself uses the@sentry/browsernpm package — already bundled into the SDK. The CDN script was fetched but never actually used. Meanwhile, theappchunk (Index.res) always initialized Sentry correctly via the bundled package directly.Fix:
Replaced the CDN
<script>tag injection block with a direct call toSentry.initiateSentryJs(~dsn=GlobalVars.sentryDSN), guarded by a check thatsentryDSNis defined. This uses the bundled@sentry/browserpackage — no external network request, no CSP dependency.Changes Summary
Modified Files:
src/hyper-loader/Hyper.res- Removed CDN script injection; replaced with direct call toSentry.initiateSentryJsusing bundled packagesrc/hyper-loader/Hyper.bs.js- Auto-generated fromHyper.resby ReScript compilerHow did you test it?
npm run re:build— compiled successfully with no errorsHyper.bs.jsno longer referencessentryScriptUrland callsinitiateSentryJsdirectlybefore:
Screen.Recording.2026-06-04.at.2.58.45.pm.mov
after:
https://github.com/user-attachments/assets/02eb0d9a-7b44-4449-a602-492c8e96235c
Checklist
npm run re:build