Skip to content

feat(node,aws-serverless): Answer managed tunnel requests on Lambda - #26000

Merged
logaretm merged 19 commits into
awad/runtime-tunnel-cloudflarefrom
awad/runtime-tunnel-lambda
Nov 6, 2026
Merged

logaretm merged 19 commits into
awad/runtime-tunnel-cloudflarefrom
awad/runtime-tunnel-lambda

Conversation

@logaretm

@logaretm logaretm commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Adds an AWS handler shim that handles tunnel events before they hit the user handler.

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: 8719ead (PR test merge using develop at c6ad7e0)

Against: 03492d2 (develop) · base run #65336

⚠️ Baseline mismatch: 34 develop commit(s) in the PR build are missing from the baseline; 2 develop commit(s) in the baseline are missing from the PR build. Their size changes also affect this comparison. Compare commits. Rebase your PR onto the latest develop to compare against an up-to-date baseline.

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.19 kB +0.85% +371 B 🔺
@sentry/core/browser 13.93 kB - -
@sentry/node 157.07 kB +0.22% +343 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.28 kB - -
@sentry/node - without tracing 96.92 kB +0.34% +325 B 🔺
@sentry/node - without channel injection 137.36 kB +0.24% +317 B 🔺
@sentry/aws-serverless 105.5 kB +0.23% +238 B 🔺
@sentry/cloudflare (withSentry) - minified 201.54 kB +0.73% +1.45 kB 🔺
@sentry/cloudflare (withSentry) 500.19 kB +0.63% +3.1 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 223.4 kB +0.66% +1.45 kB 🔺

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, 51 successful. See the run.

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

@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch 2 times, most recently from a357b59 to e260c45 Compare November 3, 2026 04:07
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch from e260c45 to 35c5803 Compare November 3, 2026 04:10
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch from 35c5803 to a2969c3 Compare November 3, 2026 04:21
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch 2 times, most recently from cbbbe3b to 335dfa3 Compare November 3, 2026 04:42
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch from 335dfa3 to 126db26 Compare November 3, 2026 04:45
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch from 126db26 to 7198f33 Compare November 3, 2026 04:50
@logaretm
logaretm marked this pull request as ready for review November 3, 2026 05:15
@logaretm
logaretm requested review from a team as code owners November 3, 2026 05:15
@logaretm
logaretm requested review from Lms24, andreiborza, isaacs, nicohrubec and s1gr1d and removed request for a team November 3, 2026 05:15

@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/node/src/lambda/tunnel.ts Resolved

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

Looks good, in line with the design of the rest of the stack. There's a few potential safety/footgun issues that could be hardened a bit.

Comment thread packages/node/src/lambda/tunnel.ts Resolved
Comment thread packages/aws-serverless/src/tunnel.ts Resolved
Comment thread packages/aws-serverless/src/tunnel.ts Resolved
Comment thread packages/aws-serverless/src/tunnel.ts Resolved
Lambda runs no HTTP server, so `serveTunnelIntegration` redirects `_HANDLER` to a shim that answers tunnel
events before the user's handler, when `init` runs from a preload. `wrapHandler` in `@sentry/aws-serverless`
answers them too. The handler resolution moves to `@sentry/node`, and its loader stays out of the main entry.
… runtime

Covers the aws-serverless and @sentry/node handler shims for async, callback and streaming handlers, the API
Gateway, ALB and base64 event shapes, and a failed forward.
esbuild leaves `import.meta` empty when it bundles our ESM build to CJS, so `fileURLToPath` threw and `Sentry.init` crashed on Lambda. The shim is now resolved like `@sentry/aws-serverless` resolves its own, and a failure only turns the tunnel off.
…ambda

The Lambda tunnel copied every header of Sentry's answer, like `connection` and `transfer-encoding`, into its result, while the Node tunnel passes on only the ones the browser SDK reads.
The streaming tunnel only logged when reading Sentry's answer failed, so Lambda held the invocation until the function timeout. It now ends the stream with a 502.
With `Sentry.init` in the handler module, the runtime already loaded the handler, so tunnel requests reached the app without a word. The SDK now warns and points to a preload or `wrapHandler`.
@logaretm
logaretm force-pushed the awad/runtime-tunnel-lambda branch from 5372683 to 2515607 Compare November 6, 2026 20:04

@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/aws-serverless/src/tunnel.ts Resolved
A CJS bundle of `@sentry/node` also warns that it can't register its diagnostics-channel hooks, which has nothing to do with the tunnel.
A REST API's `path` leaves out the stage that an HTTP API's `rawPath` keeps, so no `basePath` worked for both on a named stage. The tunnel now matches the path the browser posted to, `requestContext.path`.

@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/node/src/lambda/tunnel.ts Resolved
…rect the handler

It's a misconfiguration message, so it goes through `consoleSandbox` instead of the debug logger and shows without `debug: true`.
…ches

Which of `path` and `requestContext.path` holds the path the browser posted to depends on the domain, e.g. a custom domain with a base path mapping, so the tunnel no longer picks one.

@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 357b058. Configure here.

Comment thread packages/aws-serverless/src/tunnel.ts Resolved
…s-serverless only

The handler redirect, handler resolution and tunnel-only shim in @sentry/node shipped to every @sentry/node bundle, like Next.js server builds, for a Lambda setup we don't support. They go back to @sentry/aws-serverless, whose `wrapHandler` answers tunnel requests.
…ing `require`

Webpack can't follow `require.resolve` passed around as a value and warns, so the shim is resolved with `createRequire` from `__filename` or `import.meta.url`.
@logaretm
logaretm merged commit c5fed32 into develop Nov 6, 2026
431 of 437 checks passed
@logaretm
logaretm deleted the awad/runtime-tunnel-lambda 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