Skip to content

fix(bun): Keep diagnostics channel subscriptions alive - #24632

Draft
JPeer264 wants to merge 6 commits into
jp/node-suites-denofrom
jp/node-suites-bun-sdk-fixes
Draft

JPeer264 wants to merge 6 commits into
jp/node-suites-denofrom
jp/node-suites-bun-sdk-fixes

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Bun garbage-collects a diagnostics channel that no code references, and its subscribers with it. Node and Deno keep subscribed channels alive. The channel integrations kept no reference, so on Bun they could silently stop producing spans after the first GC. They now create their channels through wrappers in @sentry/server-utils that keep one.

@sentry/bun uses these integrations, and also httpIntegration from @sentry/node, whose channel subscriptions now go through the same wrappers. diagnosticsChannelGc.test.ts reproduces the GC on Bun.

Running the shared Node integration suites on Bun found this.

Part of #23889.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

JS-3515

@JPeer264
JPeer264 added this pull request to stack #24633 September 23, 2026 09:51
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch 2 times, most recently from 33f7607 to 77ca363 Compare September 23, 2026 10:04
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31 kB - -
@sentry/react (incl. Tracing) 53.45 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.69 kB - -
CDN Bundle (incl. Logs, Metrics) 33.2 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.42 kB - -
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.77 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.5 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB - -
@sentry/nextjs (client) 55.77 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.95 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 134 kB +0.1% +125 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.57 kB +0.21% +172 B 🔺
@sentry/node - without tracing 90.57 kB +0.18% +157 B 🔺
@sentry/node - without channel injection 112.44 kB +0.03% +33 B 🔺
@sentry/aws-serverless 98.85 kB +0.17% +158 B 🔺
@sentry/cloudflare (withSentry) - minified 206.49 kB - -
@sentry/cloudflare (withSentry) 513.73 kB - -

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from 77ca363 to 72e8bec Compare September 23, 2026 12:21
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from 72e8bec to 373d5ab Compare September 23, 2026 12:24
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from 373d5ab to 49333f3 Compare September 23, 2026 13:23
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch 2 times, most recently from 7452887 to 27c4421 Compare September 23, 2026 16:19
@JPeer264
JPeer264 removed this pull request from stack #24633 September 23, 2026 16:19
@JPeer264
JPeer264 added this pull request to stack #24670 September 23, 2026 16:19
@JPeer264 JPeer264 changed the title fix(bun, node): Fix channel GC, http.server spans and fetch spans on Bun fix(bun, node): Keep diagnostics channels alive and create http.server spans on Bun Sep 23, 2026
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from 27c4421 to ff5d855 Compare September 23, 2026 16:40
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch 2 times, most recently from b0e5f06 to 21f68ca Compare September 23, 2026 16:59
@JPeer264
JPeer264 removed this pull request from stack #24670 September 23, 2026 17:26
@JPeer264 JPeer264 changed the title fix(bun, node): Keep diagnostics channels alive and create http.server spans on Bun fix(bun): Keep diagnostics channel subscriptions alive Sep 23, 2026
@JPeer264
JPeer264 added this pull request to stack #24671 September 23, 2026 17:31
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from 763a9ee to 0b4a065 Compare September 24, 2026 09:13
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch 2 times, most recently from b3a3cf2 to ef10728 Compare September 24, 2026 14:05
JPeer264 and others added 6 commits September 24, 2026 16:17
Bun garbage-collects a diagnostics channel that no code references,
and its subscribers are lost with it. Node and Deno keep subscribed
channels alive. The channel integrations keep no reference, so on Bun
they could stop receiving messages after the next GC. They now create
their channels through wrappers that keep one.

Bun does not publish `http.server.request.start`, so `@sentry/node`
created no `http.server` span there. The `emit` patch of
`bunHttpServerIntegration` moved to `@sentry/server-utils`, and
`@sentry/node` uses it on Bun.

`nativeNodeFetchIntegration` listens on undici's channels, which the
`fetch` of Bun and Deno does not use. On these runtimes it now patches
the global `fetch` with the core instrumentation that `@sentry/bun` and
`@sentry/deno` use. `requestHook`, `responseHook` and
`headersToSpanAttributes` are not supported there yet.

The Bun and Deno exclude lists of the shared Node suites shrink
accordingly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ans on Bun

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ans on Bun

Drop the fetch fallback of nativeNodeFetchIntegration. Its module-level
createFetchIntegration() call added about 2.5 KB gzip to every
@sentry/node bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ans on Bun

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ans on Bun

Drop the http.server emit patch in @sentry/node. Bun users use
@sentry/bun, which has bunHttpServerIntegration for this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ans on Bun

Run graphql-tracing-channel on Bun, which the channel GC broke.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/node-suites-bun-sdk-fixes branch from ef10728 to 0b0863b Compare September 24, 2026 14:19

This branch has not been deployed

No deployments
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.

1 participant