Skip to content

test(e2e): Load the WebView demo's browser SDK asynchronously - #7103

Draft
antonis wants to merge 2 commits into
mainfrom
test/webview-e2e-async-cdn
Draft

antonis wants to merge 2 commits into
mainfrom
test/webview-e2e-async-cdn

Conversation

@antonis

@antonis antonis commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

The sample's WebView demo page (WebviewScreen.tsx) loaded @sentry/browser from the CDN with a blocking <script> in <head>. Until the CDN responded, the HTML parser could not reach the page's own <body> script. That script reads the injected sentry-trace meta tag and posts it back to React Native. The CDN script now loads with async, and Sentry.init runs from its onload.

Only the sample app changes, not the SDK.

💡 Motivation and Context

Fixes #7093, together with #7097. webViewTraceConnection.test.ts was the most frequent Android failure in sample-application.yml: 7 of 15 first-attempt Android failures, all with Assertion is false: "WebView trace connected.*", id: webview-trace-status is visible after the 30 s wait. The test did not fail locally under normal conditions. A slow or stalled CDN request on the CI emulator fully explains it.

💚 How did you test it?

On an emulator matching CI (API 30 aosp_atd, -gpu swiftshader_indirect), with outbound HTTPS dropped (iptables -I OUTPUT -p tcp --dport 443 -j DROP) so the CDN request hangs:

  • APK built from main: the test fails with the CI signature after 37 s, and the screen shows "WebView received: (waiting…)".
  • APK built with this change: 3/3 runs pass in 6 s. The drop rule's packet counters show it was active.
  • Without the drop rule, the change also passes.

The e2e DSN is plain HTTP while the page is served over HTTPS, so on device the browser SDK's own events are blocked as mixed content, with or without this change. To check that Sentry.init still runs, I loaded the same page logic in headless Chrome:

Page CDN Trace readback Sentry.init ran
New (async + onload) reachable ✅ ✅
New hanging ✅ no (expected)
Old (blocking) hanging ❌ parser stuck in <head> no

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

  • Watch webViewTraceConnection on main after merge, together with the test(e2e): Fix flaky sample app E2E tests #7097 fixes.
  • Separately: on Android, react-native-webview runs injectedJavaScriptBeforeContentLoaded from onPageStarted. If that runs against about:blank, our injection returns early because the hostname is empty. This is a possible SDK gap in sentryWebViewProps, not needed to explain this flake.

🤖 Generated with Claude Code

The WebView demo page loaded @sentry/browser from the CDN with a blocking
script in <head>. Until the CDN responded, the page's own script that reads
the injected sentry-trace meta tag and posts it back to React Native could
not run. On CI emulators with a slow network this outlasted the E2E wait,
so the trace status stayed "not connected" and the test failed.

Load the CDN script with async and call Sentry.init from its onload.

Refs #7093

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • test(e2e): Load the WebView demo's browser SDK asynchronously by antonis and claude in #7103
  • test(e2e): Fix flaky sample app E2E tests by antonis and claude in #7097
  • ci(ios): Build the SwiftPM app on more React Native versions by alwx in #7096
  • chore(tooling): Remove Cursor Bugbot review guidelines by antonis and claude in #7090
  • fix(core): Capture uncaught render errors on React Native 0.78+ by alwx in #7078
  • ci: Fix stale high_risk_code paths in file-filters by antonis and claude in #7091
  • ci(e2e): Fix legacy Android e2e jobs building New Architecture by antonis and claude in #7092
  • chore(deps): update Android SDK to v8.65.1 by github-actions in #7089
  • fix(core): Remove native scope tags set to an empty value by antonis and claude in #7087
  • feat(ios): Add metricKitHangReportingMode option for MetricKit hang flame graphs by alwx in #7059
  • chore(deps): bump getsentry/craft from 3.12.0 to 3.13.0 by dependabot in #7083
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 3.12.0 to 3.13.0 by dependabot in #7082
  • chore(deps): bump getsentry/github-workflows/danger from 6bf4a27612e388f9c113d64f75e25190e814b414 to bce11fe6eaa86dbb9d360ab45a96e659828877f0 by dependabot in #7081
  • chore(deps): bump actions/create-github-app-token from 3.3.0 to 3.4.0 by dependabot in #7085
  • chore(deps): bump ruby/setup-ruby from 1.338.0 to 1.342.0 by dependabot in #7084
  • chore(sample): Remove unused Detox setup from the React Native sample by antonis and claude in #7072
  • ci(ios): Build TestFlight sample with Xcode 27 by philprime with sentry-junior in #7065
  • perf(android): Create SDK view managers on demand by alwx in #7049
  • fix(core): Remove web Replay and Feedback from native bundles by default by huextrat, claude and antonis in #7062
  • fix(core): Define UnsafeObject locally instead of deep importing it by alwx in #7061
  • chore(deps): update Android SDK to v8.65.0 by github-actions in #7058

🤖 This preview updates automatically when you update the PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Nov 24, 2026
@sentry

sentry Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.36.0 (116) Release

⚙️ sentry-react-native Build Distribution Settings

@antonis
antonis marked this pull request as ready for review November 24, 2026 15:24
@antonis
antonis marked this pull request as draft November 24, 2026 15:35

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Converting back to draft since the check remains flaky

The WebView trace test only reported that the "connected" status never
appeared. Print the texts on screen, including the WebView page's own
text, so a CI failure shows whether the page never saw the injected meta
tag, the page script never ran, or the readback did not reach React
Native.

Refs #7093

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sample app E2E tests are flaky on main: 21 of 38 runs had a first-attempt failure

1 participant