Skip to content

fix(browser): Skip browserTracingIntegration setup for bot user agents#19708

Merged
chargome merged 5 commits intodevelopfrom
cg/JS-1873/sentry-browsertracing-causes-googlebot-rendering-failures
Mar 10, 2026
Merged

fix(browser): Skip browserTracingIntegration setup for bot user agents#19708
chargome merged 5 commits intodevelopfrom
cg/JS-1873/sentry-browsertracing-causes-googlebot-rendering-failures

Conversation

@chargome
Copy link
Member

@chargome chargome commented Mar 9, 2026

closes #19670

When browserTracingIntegration initializes, it creates a 30-second setTimeout (idle span final timeout), multiple PerformanceObserver instances, and various other timers. These keep the JS event loop active, which prevents Googlebot's headless Chromium renderer from considering the page "idle" — resulting in incomplete or broken page snapshots in Google Search Console.

This PR detects known bot/crawler user agents and skips the tracing setup entirely, so no timers or observers are created. Error monitoring via other integrations is unaffected.

@chargome chargome self-assigned this Mar 9, 2026
@linear-code
Copy link

linear-code bot commented Mar 9, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.64 kB +0.05% +12 B 🔺
@sentry/browser - with treeshaking flags 24.14 kB +0.03% +7 B 🔺
@sentry/browser (incl. Tracing) 42.62 kB +0.45% +189 B 🔺
@sentry/browser (incl. Tracing, Profiling) 47.28 kB +0.41% +189 B 🔺
@sentry/browser (incl. Tracing, Replay) 81.43 kB +0.23% +184 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 71.01 kB +0.2% +141 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 86.14 kB +0.23% +192 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 98.39 kB +0.19% +185 B 🔺
@sentry/browser (incl. Feedback) 42.44 kB +0.02% +7 B 🔺
@sentry/browser (incl. sendFeedback) 30.31 kB +0.04% +11 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.36 kB +0.04% +11 B 🔺
@sentry/browser (incl. Metrics) 26.8 kB +0.04% +9 B 🔺
@sentry/browser (incl. Logs) 26.95 kB +0.03% +8 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.62 kB +0.04% +9 B 🔺
@sentry/react 27.39 kB +0.04% +9 B 🔺
@sentry/react (incl. Tracing) 44.95 kB +0.41% +182 B 🔺
@sentry/vue 30.09 kB +0.04% +10 B 🔺
@sentry/vue (incl. Tracing) 44.49 kB +0.42% +186 B 🔺
@sentry/svelte 25.66 kB +0.04% +9 B 🔺
CDN Bundle 28.18 kB +0.04% +9 B 🔺
CDN Bundle (incl. Tracing) 43.41 kB +0.36% +152 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.02 kB +0.04% +9 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.25 kB +0.33% +144 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.1 kB +0.02% +8 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.27 kB +0.17% +133 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.13 kB +0.16% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.78 kB +0.16% +131 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.67 kB +0.16% +134 B 🔺
CDN Bundle - uncompressed 82.38 kB +0.04% +26 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 128.36 kB +0.23% +288 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.21 kB +0.04% +26 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.19 kB +0.23% +288 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.88 kB +0.02% +26 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 245.24 kB +0.12% +288 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.06 kB +0.12% +288 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 258.15 kB +0.12% +288 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.96 kB +0.12% +288 B 🔺
@sentry/nextjs (client) 47.37 kB +0.4% +186 B 🔺
@sentry/sveltekit (client) 43.07 kB +0.43% +181 B 🔺
@sentry/node-core 52.27 kB +0.07% +34 B 🔺
@sentry/node 174.77 kB +0.04% +62 B 🔺
@sentry/node - without tracing 97.44 kB +0.06% +53 B 🔺
@sentry/aws-serverless 113.24 kB +0.05% +49 B 🔺

View base workflow run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,856 - 9,389 -6%
GET With Sentry 1,629 18% 1,709 -5%
GET With Sentry (error only) 6,079 69% 6,041 +1%
POST Baseline 1,173 - 1,208 -3%
POST With Sentry 564 48% 589 -4%
POST With Sentry (error only) 1,033 88% 1,065 -3%
MYSQL Baseline 3,248 - 3,242 +0%
MYSQL With Sentry 495 15% 436 +14%
MYSQL With Sentry (error only) 2,668 82% 2,650 +1%

View base workflow run

chargome and others added 2 commits March 9, 2026 13:11
… prevent CI timeout

The first dynamic import after vi.resetModules() needs to compile the
entire SDK module graph from scratch, which can hang on slower CI runners.
Pre-importing the modules in beforeAll warms the V8 compilation cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chargome chargome requested review from Lms24 and s1gr1d March 9, 2026 13:55
Comment on lines +23 to +31
beforeAll(async () => {
// Pre-warm V8 compilation cache for the large SDK module graphs.
// Without this, the first dynamic import after vi.resetModules() can hang
// because vitest needs to compile the entire module graph from scratch.
await import('../../src/client/index.js');
await import('../../src/server/index.js');
await import('../../src/edge/index.js');
vi.resetModules();

Copy link
Member Author

Choose a reason for hiding this comment

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

unrelated but these tests are flaky on node 20 and this fixes it

@chargome chargome marked this pull request as ready for review March 9, 2026 14:09
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.

LGTM! For future reference, Relay has an extensive list of web crawlers (including some they explicitly allow). Adding all of these here would be bundle size overkill IMO, so this subset seems fine as it seems to cover the most important ones.

@chargome chargome merged commit 7bfe71c into develop Mar 10, 2026
226 checks passed
@chargome chargome deleted the cg/JS-1873/sentry-browsertracing-causes-googlebot-rendering-failures branch March 10, 2026 11:00
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.

Sentry BrowserTracing causes Googlebot rendering failures

2 participants