Skip to content

feat(node,bun,deno): Answer managed tunnel requests in the runtime - #25998

Merged
logaretm merged 11 commits into
awad/runtime-tunnel-corefrom
awad/runtime-tunnel-node-bun-deno
Nov 6, 2026
Merged

logaretm merged 11 commits into
awad/runtime-tunnel-corefrom
awad/runtime-tunnel-node-bun-deno

Conversation

@logaretm

@logaretm logaretm commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

This PR actually delivers the approach outlined in #25997 by hooking up the new utilities and wiring them up to the runtimes appropriately.

The implementation introduces a new integration factory that creates an integration for each runtime, it accepts a runtime-specific server patcher, and it applies the HTTP patch itself.

For Node.js / http module

For Node, and other runtimes that emit the http module's diagnostic channel, we patch the server emit and handle the request before it ever hits the user application.

For Deno / Bun

It does the same thing as in Node, but also adds a *.serve patch in-case the user is using the native runtime servers.

Note for reviewers: if you are lacking context on this PR, check #25997

@logaretm
logaretm added this pull request to stack #26002 November 2, 2026 19:44
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 46cffcf (PR test merge using develop at 31201fb)

Against: 2f26678 (develop) · base run #65292

⚠️ Baseline mismatch: 17 develop commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once develop's baseline build for 31201fb finishes.

Path Size % Change Change
@sentry/browser 29.92 kB - -
@sentry/browser - with treeshaking flags 28.08 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.97 kB - -
@sentry/browser (incl. Tracing) 52.2 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.22 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.18 kB - -
@sentry/browser (incl. Tracing, Replay) 92.52 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.2 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.25 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.25 kB - -
@sentry/browser (incl. Feedback) 47.52 kB - -
@sentry/browser (incl. sendFeedback) 35.02 kB - -
@sentry/browser (incl. FeedbackAsync) 40.13 kB - -
@sentry/browser (incl. Metrics) 31.48 kB - -
@sentry/browser (incl. Logs) 31.77 kB - -
@sentry/browser (incl. Metrics & Logs) 32.45 kB - -
@sentry/react 31.78 kB - -
@sentry/react (incl. Tracing) 54.62 kB - -
@sentry/vue 38.24 kB - -
@sentry/vue (incl. Tracing) 55.24 kB - -
@sentry/svelte 29.95 kB - -
@sentry/remix (Remix 3 client bundle) 57.83 kB - -
CDN Bundle 31.72 kB - -
CDN Bundle (incl. Tracing) 52.81 kB - -
CDN Bundle (incl. Logs, Metrics) 34.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.32 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.9 kB - -
CDN Bundle (incl. Tracing, Replay) 90.98 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.54 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.11 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.71 kB - -
CDN Bundle - uncompressed 92.76 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.77 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.55 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.85 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.46 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.17 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.92 kB - -
@sentry/nextjs (client) 57.64 kB - -
@sentry/sveltekit (client) 52.73 kB - -
@sentry/core/server 44.17 kB +0.81% +354 B 🔺
@sentry/core/browser 13.93 kB - -
@sentry/node 157.07 kB +0.22% +342 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.28 kB - -
@sentry/node - without tracing 96.92 kB +0.34% +323 B 🔺
@sentry/node - without channel injection 137.36 kB +0.24% +317 B 🔺
@sentry/aws-serverless 105.56 kB +0.29% +298 B 🔺
@sentry/cloudflare (withSentry) - minified 200.99 kB +0.45% +895 B 🔺
@sentry/cloudflare (withSentry) 498.92 kB +0.37% +1.82 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 222.85 kB +0.41% +895 B 🔺

View base workflow run

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 6 not successful, 50 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
❌ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Failing after 28s Details
❌ CI: Optional E2E Tests / E2E node-eve Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Failing after 33s Details
❌ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Failing after 59s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E astro-7-static 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 nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (tunnel-dev) Test (optional) Successful in 50s 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 debug-id-sourcemaps Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs 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 cloudflare-mastra Test (optional) Successful in 51s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details

@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch 5 times, most recently from 86e706c to 0a00c73 Compare November 3, 2026 04:28
@logaretm
logaretm marked this pull request as ready for review November 3, 2026 04:53
@logaretm
logaretm requested review from a team as code owners November 3, 2026 04:53
@logaretm
logaretm requested review from Lms24, andreiborza, isaacs, msonnb, nicohrubec and s1gr1d and removed request for a team November 3, 2026 04:53
@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from ff78a0d to a92ac02 Compare November 4, 2026 17:25

@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.

Stale Bugbot comment from a previous run.

@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from a92ac02 to e35e392 Compare November 5, 2026 16:17

@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.

Stale Bugbot comment from a previous run.

Comment thread packages/bun/src/tunnelServer.ts Resolved
Comment thread packages/bun/src/tunnelServer.ts Resolved
@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from e35e392 to f3239a8 Compare November 5, 2026 20:23
Comment on lines +31 to +34
if (options.intercept !== false) {
instrumentTunnelServers();
instrumentRuntimeServers?.();
}

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.

Bugbot raised this somewhat weirdly phrased imo, but there's a real issue here.

setupOnce runs once per integration name per process. If the first serveTunnelIntegration set up has intercept: false, then a later client or addIntegration with intercept: true won't install the hooks. Its tunnel requests then go to the app. The reverse case is harmless.

The gate doesn't buy much. Each hook reads intercept per request through getServedTunnelMatch, so with intercept: false installed hooks hand every request to the app anyway. TanStack already installs the hooks without any gate.

Suggestion: drop the if and always install in setupOnce. If the cost of a no-op emit wrapper with intercept: false matters, install from setup(client) when that client's intercept is not false. The install functions already keep their own "done once" flags.

Suggested change
if (options.intercept !== false) {
instrumentTunnelServers();
instrumentRuntimeServers?.();
}
instrumentTunnelServers();
instrumentRuntimeServers?.();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This would only be relevant if multiple clients exist, so that's why I ignored it.

Having multiple clients with two active tunnel configurations is not valid. I would have did it but Bun's hook adds a POST route for the tunnel path, which means we cannot have it both ways.

So this behaviors makes it uniform across runtimes, but leaving this edge case as a gap.

Happy to revisit if you think otherwise.

Comment thread packages/bun/src/tunnelServer.ts Resolved
Comment thread packages/node/src/index.ts Resolved
@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from f3239a8 to 1ce6dab Compare November 5, 2026 21:58

@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.

Stale Bugbot comment from a previous run.

@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from 32a4161 to 2918f88 Compare November 6, 2026 02:01

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2918f88. Configure here.

Comment thread packages/bun/src/tunnelServer.ts Resolved
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

One or more gzipped bundles increased by more than 500 bytes. If this increase is intentional, add the Accept Bundlesize Increase label to this PR to rerun and accept the check.

`serveTunnelIntegration` answers tunnel requests on every `node:http` server (through the
`http.server.request.start` diagnostics channel), `Bun.serve` and `Deno.serve` before the app sees them.
TanStack Start's `init` installs the hooks itself, since `tunnelRoute` enables the tunnel after `init`.

Every runtime gets the same set of malformed and hostile requests, to prove the app keeps working.
…s emit wrapper

With both wrappers on `emit`, the HTTP one wrapped again on the second request, so every request passed two HTTP
proxies, and anything replacing `emit` later dropped the tunnel. The HTTP wrapper now answers tunnel requests
itself, and the separate tunnel wrapper is only installed without it.
The tunnel wrapped `fetch` and replaced `routes` on the app's own options object, so passing the same object to
`server.reload` wrapped our wrappers again. Options a class gives through a `fetch` getter threw on the assignment
and got no tunnel.
Core's HTTP server instrumentation imported the tunnel's Node handler, so every Node and Cloudflare bundle carried
it. The tunnel now registers the handler in the tunnel store when its hooks install, and the instrumentation calls it
from there.
@logaretm
logaretm force-pushed the awad/runtime-tunnel-node-bun-deno branch from 033d6b4 to c7c0c3f Compare November 6, 2026 20:04
@logaretm
logaretm merged commit 0da0b0c into develop Nov 6, 2026
795 of 835 checks passed
@logaretm
logaretm deleted the awad/runtime-tunnel-node-bun-deno branch November 6, 2026 22:46
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.

2 participants