Skip to content

fix(cloudflare): Have @flue/runtime provide its own namespace - #25935

Open
mydea wants to merge 4 commits into
developfrom
fix/cloudflare-flue-self-provided-runtime
Open

mydea wants to merge 4 commits into
developfrom
fix/cloudflare-flue-self-provided-runtime

Conversation

@mydea

@mydea mydea commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Why: flueIntegration needs Flue's own instrument(), which a bundled worker can't resolve at runtime. @sentry/cloudflare/vite used to splice an @flue/runtime import into @sentry/server-utils's Flue integration for that. Every orchestrion-instrumented module imports @sentry/server-utils, so that import closes a cycle through any instrumented package Flue loads at module scope. With pi-ai instrumented (the upcoming pi-ai integration, split out of #25869), a worker that reaches pi-ai first runs Flue's module-level createModels() before pi-ai's ModelsImpl exists. I reproduced it locally with cloudflare-flue-send-to-sentry: the worker fails at startup with Cannot access 'ModelsImpl' before initialization.

Flue's entry is already transformed at build time, so it now publishes its own namespace through a self-import.

There are now two ways to hand a package to an integration in a bundled worker. Which one to use depends on whether the app already imports the package:

Self-provided (selfProvidedModules, new) Provided-module plugin (existing)
Used for @flue/runtime @mastra/observability
Use when the app imports the package anyway, and it is in Sentry's orchestrion config the app never imports the package; the integration needs it anyway
Injected into the package's own entry: import * as ns from './index.mjs' Sentry's integration module: import * as ns from '@mastra/observability'
Module graph no new edge, so no cycle possible adds the edge, which is what pulls the package into the bundle

Mastra can't switch to the self-provided path: apps don't import @mastra/observability (Mastra's observability is zero-config), so nothing would load it and it would never publish itself. Its splice has the same cycle shape (@mastra/observability imports @mastra/core, which is instrumented). That is harmless today because it only imports core subpaths that aren't transformed. If that changes, the splice can move into @sentry/cloudflare's own module, out of @sentry/server-utils.

selfProvidedModules is Cloudflare-only on purpose. On other bundlers, flueIntegration would then register Flue itself and clash with apps that call instrument(Sentry.createFlueInstrumentation()), as our Node docs say. The webpack loader doesn't pass the option.

How to review: Start with selfProvidedSnippet in moduleInjectedTransform.ts; its comment shows the generated output. The rest is wiring, removing Flue's provided-module plugin, and comments.

Unsure about: Whether the Mastra splice should move out of @sentry/server-utils now, before it can hit the same kind of cycle. I'd leave it until something actually triggers it.

🤖 Generated with Claude Code

`@sentry/cloudflare/vite` spliced an `@flue/runtime` import into
`@sentry/server-utils`'s Flue integration. Every orchestrion-instrumented
module imports `@sentry/server-utils`, so that import closes a cycle through
any instrumented package Flue loads at module scope. Once pi-ai is
instrumented, a worker that reaches pi-ai first runs Flue's module-level
`createModels()` before pi-ai's `ModelsImpl` exists and fails at startup.

Flue's entry is already transformed, so it now publishes its own namespace
through a self-import, which adds no edge to the module graph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: bf5433a (PR test merge using develop at 365e761)

Against: 365e761 (develop) · base run #64341

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

Path Size % Change Change
@sentry/browser 30.39 kB - -
@sentry/browser - with treeshaking flags 28.53 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.42 kB - -
@sentry/browser (incl. Tracing) 52.71 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.72 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.69 kB - -
@sentry/browser (incl. Tracing, Replay) 93.01 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.61 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.76 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.75 kB - -
@sentry/browser (incl. Feedback) 47.97 kB - -
@sentry/browser (incl. sendFeedback) 35.49 kB - -
@sentry/browser (incl. FeedbackAsync) 40.6 kB - -
@sentry/browser (incl. Metrics) 31.42 kB - -
@sentry/browser (incl. Logs) 31.72 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.27 kB - -
@sentry/react (incl. Tracing) 55.07 kB - -
@sentry/vue 38.66 kB - -
@sentry/vue (incl. Tracing) 55.73 kB - -
@sentry/svelte 30.42 kB - -
@sentry/remix (Remix 3 client bundle) 57.8 kB - -
CDN Bundle 32.18 kB - -
CDN Bundle (incl. Tracing) 53.23 kB - -
CDN Bundle (incl. Logs, Metrics) 34.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.18 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.86 kB - -
CDN Bundle (incl. Tracing, Replay) 91.44 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.56 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.55 kB - -
CDN Bundle - uncompressed 94.62 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.6 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.09 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.33 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.65 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.29 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.7 kB - -
@sentry/nextjs (client) 57.89 kB - -
@sentry/sveltekit (client) 53.22 kB - -
@sentry/core/server 44.24 kB - -
@sentry/core/browser 13.93 kB - -
@sentry/node 155.02 kB +0.02% +22 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.08 kB - -
@sentry/node - without tracing 96.23 kB +0.03% +20 B 🔺
@sentry/node - without channel injection 135.43 kB +0.01% +10 B 🔺
@sentry/aws-serverless 104.43 kB +0.03% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 197.92 kB - -
@sentry/cloudflare (withSentry) 491.93 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 218.35 kB - -

View base workflow run

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 2 not successful, 53 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry (latest) Test (optional) Failing after 3m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) 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 cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 15s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 16s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 38s Details

mydea and others added 2 commits October 30, 2026 11:34
…ig test

The Cloudflare plugin test only echoed the option it passes. The transform
tests and the cloudflare-flue-send-to-sentry e2e app cover the behavior.

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea
mydea marked this pull request as ready for review October 30, 2026 11:00
@mydea
mydea requested a review from a team as a code owner October 30, 2026 11:00
@mydea
mydea requested review from andreiborza and isaacs and removed request for a team October 30, 2026 11:00
@mydea
mydea requested a review from JPeer264 October 30, 2026 13:10

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