Skip to content

fix(nextjs): skip custom browser tracing setup for bot user agents#20263

Open
logaretm wants to merge 1 commit intodevelopfrom
awad/js-1873-sentry-browsertracing-causes-googlebot-rendering-failures
Open

fix(nextjs): skip custom browser tracing setup for bot user agents#20263
logaretm wants to merge 1 commit intodevelopfrom
awad/js-1873-sentry-browsertracing-causes-googlebot-rendering-failures

Conversation

@logaretm
Copy link
Copy Markdown
Member

@logaretm logaretm commented Apr 13, 2026

Exposes isBotUserAgent() from the browser tracing integration to use it in the Next.js browser tracing wrapper so bot user agents also skip Next.js-specific router instrumentation which adds its own interval timer.

This is intentionally the smallest change to test whether this fixes the Googlebot rendering issue.

Longer term, we probably want a more general mechanism for integrations to skip their own setup, with a skip decision that can be downstreamed easily through wrappers and integration variants instead of checking the bot predicate ad hoc in each package.

closes #19670

Expose isBotUserAgent from the browser tracing integration and use it in the Next.js wrapper so bot user agents also skip the Next.js-specific router instrumentation path.

This is the smallest change to validate the fix. Longer term, we probably want a more general mechanism for integrations to skip their own setup and make that skip decision easy to downstream through wrappers and variants.

Co-Authored-By: GPT-5.4 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 13, 2026 18:25
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 13, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

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


New Features ✨

Cloudflare

  • Split alarms into multiple traces and link them by JPeer264 in #19373
  • Propagate traceparent to RPC calls - via fetch by JPeer264 in #19991

Core

  • Automatically disable truncation when span streaming is enabled in LangGraph integration by andreiborza in #20231
  • Automatically disable truncation when span streaming is enabled in LangChain integration by andreiborza in #20230
  • Automatically disable truncation when span streaming is enabled in Google GenAI integration by andreiborza in #20229
  • Automatically disable truncation when span streaming is enabled in Anthropic AI integration by andreiborza in #20228
  • Automatically disable truncation when span streaming is enabled in Vercel AI integration by andreiborza in #20232
  • Automatically disable truncation when span streaming is enabled in OpenAI integration by andreiborza in #20227
  • Add enableTruncation option to Vercel AI integration by nicohrubec in #20195
  • Add enableTruncation option to Google GenAI integration by andreiborza in #20184
  • Add enableTruncation option to Anthropic AI integration by andreiborza in #20181
  • Add enableTruncation option to LangGraph integration by andreiborza in #20183
  • Add enableTruncation option to LangChain integration by andreiborza in #20182
  • Add enableTruncation option to OpenAI integration by andreiborza in #20167
  • Export a reusable function to add tracing headers by JPeer264 in #20076

Deps

  • Bump axios from 1.13.5 to 1.15.0 by dependabot in #20180
  • Bump hono from 4.12.7 to 4.12.12 by dependabot in #20118
  • Bump defu from 6.1.4 to 6.1.6 by dependabot in #20104

Other

  • (node) Include global scope for eventLoopBlockIntegration by timfish in #20108
  • (node-native) Add support for V8 v14 (Node v25+) by timfish in #20125

Bug Fixes 🐛

Deno

  • Handle reader.closed rejection from releaseLock() in streaming by andreiborza in #20187
  • Avoid inferring invalid span op from Deno tracer by Lms24 in #20128

Other

  • (ci) Prevent command injection in ci-metadata workflow by fix-it-felix-sentry in #19899
  • (core, node) Support loading Express options lazily by isaacs in #20211
  • (e2e) Add op check to waitForTransaction in React Router e2e tests by copilot-swe-agent in #20193
  • (nextjs) Skip custom browser tracing setup for bot user agents by logaretm in #20263
  • (node-integration-tests) Fix flaky kafkajs test race condition by copilot-swe-agent in #20189

Internal Changes 🔧

Ci

  • Remove node-overhead GitHub Action by mydea in #20246
  • Bump dorny/paths-filter from v3.0.1 to v4.0.1 by mydea in #20251
  • Remove codecov steps from jobs that produce no coverage/JUnit data by mydea in #20244

Deps

  • Bump hono from 4.12.7 to 4.12.12 in /dev-packages/e2e-tests/test-applications/cloudflare-hono by dependabot in #20119
  • Bump axios from 1.13.5 to 1.15.0 in /dev-packages/e2e-tests/test-applications/nestjs-basic by dependabot in #20179

Other

  • (bugbot) Add rules to flag test-flake-provoking patterns by Lms24 in #20192
  • (deps-dev) Bump vite from 7.2.0 to 7.3.2 in /dev-packages/e2e-tests/test-applications/tanstackstart-react by dependabot in #20107
  • (react) Remove duplicated test mock by s1gr1d in #20200
  • (size-limit) Bump failing size limit scenario by Lms24 in #20186
  • Fix lint warnings by mydea in #20250
  • Fix flaky ANR test by increasing blocking duration by JPeer264 in #20239
  • Add automatic flaky test detector by nicohrubec in #18684

🤖 This preview updates automatically when you update the PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses bot-rendering issues in Next.js by ensuring bot user agents (e.g. Googlebot) don’t trigger Next.js-specific router instrumentation (notably the router polling timer), by reusing a shared bot user-agent predicate from the browser tracing integration.

Changes:

  • Export isBotUserAgent() from the Browser Tracing integration (and re-export it via @sentry/browser bundles).
  • Use isBotUserAgent() in the Next.js Browser Tracing wrapper to skip Next.js router instrumentation for bots.
  • Add a Next.js unit regression test to ensure Googlebot doesn’t start the router polling interval.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/nextjs/src/client/browserTracingIntegration.ts Skips Next.js router instrumentation in afterAllSetup for bot user agents.
packages/nextjs/test/clientSdk.test.ts Adds regression test asserting no setInterval polling starts for Googlebot.
packages/browser/src/tracing/browserTracingIntegration.ts Makes bot UA detection helper public (isBotUserAgent) and uses it internally.
packages/browser/src/index.ts Re-exports isBotUserAgent from the browser package entrypoint.
packages/browser/src/index.bundle.tracing.ts Re-exports isBotUserAgent in tracing bundle.
packages/browser/src/index.bundle.tracing.replay.ts Re-exports isBotUserAgent in tracing+replay bundle.
packages/browser/src/index.bundle.tracing.replay.logs.metrics.ts Re-exports isBotUserAgent in tracing+replay+logs+metrics bundle.
packages/browser/src/index.bundle.tracing.replay.feedback.ts Re-exports isBotUserAgent in tracing+replay+feedback bundle.
packages/browser/src/index.bundle.tracing.replay.feedback.logs.metrics.ts Re-exports isBotUserAgent in tracing+replay+feedback+logs+metrics bundle.
packages/browser/src/index.bundle.tracing.logs.metrics.ts Re-exports isBotUserAgent in tracing+logs+metrics bundle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +178 to +183
init({
dsn: TEST_DSN,
tracesSampleRate: 1.0,
});

expect(setIntervalSpy).not.toHaveBeenCalled();
@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.72 kB - -
@sentry/browser - with treeshaking flags 24.21 kB - -
@sentry/browser (incl. Tracing) 42.73 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.36 kB - -
@sentry/browser (incl. Tracing, Replay) 81.54 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 71.11 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 86.25 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.46 kB - -
@sentry/browser (incl. Feedback) 42.51 kB - -
@sentry/browser (incl. sendFeedback) 30.39 kB - -
@sentry/browser (incl. FeedbackAsync) 35.38 kB - -
@sentry/browser (incl. Metrics) 27.04 kB - -
@sentry/browser (incl. Logs) 27.18 kB - -
@sentry/browser (incl. Metrics & Logs) 27.86 kB - -
@sentry/react 27.48 kB - -
@sentry/react (incl. Tracing) 45.06 kB - -
@sentry/vue 30.56 kB - -
@sentry/vue (incl. Tracing) 44.6 kB - -
@sentry/svelte 25.74 kB - -
CDN Bundle 28.41 kB - -
CDN Bundle (incl. Tracing) 43.78 kB +0.04% +16 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.78 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.85 kB +0.04% +14 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.59 kB - -
CDN Bundle (incl. Tracing, Replay) 80.66 kB +0.03% +17 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.69 kB +0.04% +28 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 86.18 kB +0.02% +12 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 87.22 kB +0.02% +13 B 🔺
CDN Bundle - uncompressed 82.99 kB - -
CDN Bundle (incl. Tracing) - uncompressed 129.82 kB +0.03% +31 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 133.23 kB +0.03% +31 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 210.12 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 246.7 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 250.09 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 259.61 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 263 kB +0.02% +31 B 🔺
@sentry/nextjs (client) 47.49 kB +0.02% +8 B 🔺
@sentry/sveltekit (client) 43.2 kB - -
@sentry/node-core 57.85 kB +0.01% +5 B 🔺
@sentry/node 175.07 kB +0.01% +8 B 🔺
@sentry/node - without tracing 97.97 kB +0.03% +21 B 🔺
@sentry/aws-serverless 115.22 kB +0.02% +18 B 🔺

View base workflow run

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