Skip to content

fix(node): Skip spans for outgoing requests to Sentry via undici fetch and node:http - #25441

Merged
Lms24 merged 4 commits into
developfrom
lms/fix-node-fetch-ignore-sentry-requests
Oct 23, 2026
Merged

Lms24 merged 4 commits into
developfrom
lms/fix-node-fetch-ignore-sentry-requests

Conversation

@Lms24

@Lms24 Lms24 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

This PR fixes a bug where undici and http client instrumentation created spans for requests to the sentry ingest endpoint. We now skip requests to the client's DSN or tunnel via isSentryRequestUrl, like we already do in our fetch integrations (node, cloudflare, vercel edge). This checks the raw URL, so it works regardless of dataCollection.urlQueryParams.

This surfaced in NextJS while working on #25386, where apparently we'd start spans in standalone (node, preview, dev) Next environments. Based on Claude research this happened because of NextJS sandboxing the edge runtime requests in a sub process of the Node process and our instrumentation catching those calls in both, the sandbox and the main process. The fix therefore replaces the Next.js beforeSampling drop for these spans, which only applied to root spans and has accidentally not been enforced since SentrySampler was removed.

@Lms24 Lms24 changed the title fix(node): Skip spans for outgoing requests to Sentry fix(node): Skip spans for outgoing requests to Sentry via undici fetch Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: d207974 (PR test merge using develop at 07b8868)

Against: 07b8868 (develop) · base run #63324

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 29.98 kB - -
@sentry/browser - with treeshaking flags 28.12 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.02 kB - -
@sentry/browser (incl. Tracing) 52.16 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.16 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.11 kB - -
@sentry/browser (incl. Tracing, Replay) 91.95 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.84 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.69 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.62 kB - -
@sentry/browser (incl. Feedback) 47.5 kB - -
@sentry/browser (incl. sendFeedback) 35.04 kB - -
@sentry/browser (incl. FeedbackAsync) 40.15 kB - -
@sentry/browser (incl. Metrics) 31 kB - -
@sentry/browser (incl. Logs) 31.27 kB - -
@sentry/browser (incl. Metrics & Logs) 31.93 kB - -
@sentry/react 31.8 kB - -
@sentry/react (incl. Tracing) 54.49 kB - -
@sentry/vue 38.13 kB - -
@sentry/vue (incl. Tracing) 55.1 kB - -
@sentry/svelte 30 kB - -
@sentry/remix (Remix 3 client bundle) 57.19 kB - -
CDN Bundle 31.74 kB - -
CDN Bundle (incl. Tracing) 52.7 kB - -
CDN Bundle (incl. Logs, Metrics) 33.94 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.65 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.92 kB - -
CDN Bundle (incl. Tracing, Replay) 90.4 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.32 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.54 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.49 kB - -
CDN Bundle - uncompressed 93.49 kB - -
CDN Bundle (incl. Tracing) - uncompressed 156.34 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 162.31 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 230.25 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 276.69 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 282.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 290.39 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 296.33 kB - -
@sentry/nextjs (client) 57.38 kB - -
@sentry/sveltekit (client) 52.54 kB - -
@sentry/core/server 41.87 kB +0.06% +21 B 🔺
@sentry/core/browser 13.81 kB - -
@sentry/node 153.13 kB +0.11% +168 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.58 kB - -
@sentry/node - without tracing 94.72 kB +0.16% +149 B 🔺
@sentry/node - without channel injection 133.76 kB +0.12% +159 B 🔺
@sentry/aws-serverless 102.88 kB +0.14% +136 B 🔺
@sentry/cloudflare (withSentry) - minified 193.71 kB - -
@sentry/cloudflare (withSentry) 481.82 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 214.38 kB -0.12% -241 B 🔽

View base workflow run

@Lms24 Lms24 changed the title fix(node): Skip spans for outgoing requests to Sentry via undici fetch fix(node): Skip spans for outgoing requests to Sentry via undici fetch and node:http Oct 16, 2026
@Lms24 Lms24 self-assigned this Oct 16, 2026
@Lms24

Lms24 commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 56f0f4b. Configure here.

@Lms24
Lms24 marked this pull request as ready for review October 16, 2026 10:05
@Lms24
Lms24 requested review from a team as code owners October 16, 2026 10:05
@Lms24
Lms24 requested review from JPeer264, chargome, mydea and s1gr1d and removed request for a team October 16, 2026 10:05

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing. Thanks a lot for fixing that


// Bun before 1.4 does not instrument outgoing `node:http` requests.
// See https://github.com/getsentry/sentry-javascript/issues/23881
describe.runIf(supports({ bunMin: '1.4.0' }))('outgoing http requests to Sentry', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for not skipping this entirely and enable it for the min version 🙏

Lms24 added 2 commits October 23, 2026 10:27
Our own transport sends with tracing suppressed, but another SDK in the same
process does not share that scope. On Next.js, the Edge Runtime SDK runs in a
sandbox inside the Node.js process and sends with undici `fetch`, so the
Node.js SDK created `http.client` spans for these requests.

Skip requests to the client's DSN or tunnel in the undici and `http` client
instrumentation, like the `fetch` integration already does. This replaces the
Next.js `beforeSampling` drop, which only applied to root spans and was no
longer enforced.

Co-Authored-By: Lukas Stracke <lukas.stracke@sentry.io>
`@sentry/node` cannot instrument `fetch` on Bun and Deno, so the fetch suite
joins the other fetch suites in their exclude lists.

Co-Authored-By: Lukas Stracke <lukas.stracke@sentry.io>
@sentry-junior
sentry-junior Bot force-pushed the lms/fix-node-fetch-ignore-sentry-requests branch from cbf829a to 4c4b377 Compare October 23, 2026 10:28
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 63 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry (latest) Test (optional) Failing after 16s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E angular (canary) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E angular (canary) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (canary, turbopack) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-3 (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (canary, webpack) Test (optional) Successful in 7m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (canary) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-standalone (canary, turbopack) Test (optional) Successful in 51s Details
✅ CI: Optional E2E Tests / E2E nuxt-4 (canary) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions-send-to-sentry (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-static (canary) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 50s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 28s Details

Lms24 and others added 2 commits October 23, 2026 13:16
Co-authored-by: Jan Peer Stöcklmair <jan.peer@sentry.io>
Co-Authored-By: Lukas Stracke <lukas.stracke@sentry.io>
@Lms24
Lms24 merged commit 067ae23 into develop Oct 23, 2026
682 of 685 checks passed
@Lms24
Lms24 deleted the lms/fix-node-fetch-ignore-sentry-requests branch October 23, 2026 11:56
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.

3 participants