Skip to content

fix(cloudflare): Keep an installed OpenTelemetry async context strategy - #24995

Open
JPeer264 wants to merge 1 commit into
developfrom
jp/cloudflare-keep-otel-async-context-strategy
Open

JPeer264 wants to merge 1 commit into
developfrom
jp/cloudflare-keep-otel-async-context-strategy

Conversation

@JPeer264

@JPeer264 JPeer264 commented Oct 2, 2026

Copy link
Copy Markdown
Member

withSentry, Durable Objects, Workflows and WorkerEntrypoint install the AsyncLocalStorage async context strategy. When an OpenTelemetry strategy is already installed, the new strategy reuses its AsyncLocalStorage but stores Sentry scopes in it. The OpenTelemetry context manager then reads a scope store as a context, and every later request fails with context.getValue is not a function (#24603). They now keep an installed OpenTelemetry strategy.

This is needed for @sentry/nextjs/cloudflare, which installs the OpenTelemetry strategy before it calls withSentry, and for apps whose register() runs before the Worker entry. The check uses withActiveSpan, which only the OpenTelemetry strategy has, so no new marker is needed. The Pages plugin is unchanged.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.52 kB - -
@sentry/browser - with treeshaking flags 27.68 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.57 kB - -
@sentry/browser (incl. Tracing) 51.42 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.44 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.44 kB - -
@sentry/browser (incl. Tracing, Replay) 91.03 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.03 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.73 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.68 kB - -
@sentry/browser (incl. Feedback) 47.02 kB - -
@sentry/browser (incl. sendFeedback) 34.58 kB - -
@sentry/browser (incl. FeedbackAsync) 39.68 kB - -
@sentry/browser (incl. Metrics) 30.53 kB - -
@sentry/browser (incl. Logs) 30.82 kB - -
@sentry/browser (incl. Metrics & Logs) 31.47 kB - -
@sentry/react 31.36 kB - -
@sentry/react (incl. Tracing) 53.78 kB - -
@sentry/vue 37.49 kB - -
@sentry/vue (incl. Tracing) 54.34 kB - -
@sentry/svelte 29.55 kB - -
@sentry/remix (Remix 3 client bundle) 55.78 kB - -
CDN Bundle 31.22 kB - -
CDN Bundle (incl. Tracing) 51.98 kB - -
CDN Bundle (incl. Logs, Metrics) 33.46 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.92 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.21 kB - -
CDN Bundle (incl. Tracing, Replay) 89.54 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.51 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.72 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.71 kB - -
CDN Bundle - uncompressed 92.14 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.49 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.71 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 160.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.28 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 274.22 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 280.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.92 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.85 kB - -
@sentry/nextjs (client) 56.31 kB - -
@sentry/sveltekit (client) 51.85 kB - -
@sentry/core/server 40.58 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 144.75 kB +0.01% +12 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.22 kB - -
@sentry/node - without tracing 93.31 kB +0.01% +8 B 🔺
@sentry/node - without channel injection 122.96 kB +0.02% +13 B 🔺
@sentry/aws-serverless 101.58 kB +0.01% +9 B 🔺
@sentry/cloudflare (withSentry) - minified 208.73 kB +0.06% +106 B 🔺
@sentry/cloudflare (withSentry) 517.65 kB +0.08% +401 B 🔺

View base workflow run

Base automatically changed from jp/react-router-8-cloudflare-into-framework to develop October 5, 2026 08:43
@JPeer264
JPeer264 added this pull request to stack #25035 October 5, 2026 08:43
`withSentry`, Durable Objects, Workflows and `WorkerEntrypoint` install the
AsyncLocalStorage async context strategy. When an OpenTelemetry strategy
already uses the same storage, replacing it while a request runs makes the
OpenTelemetry context manager read a Sentry scope store as a context, and
every later request fails with `context.getValue is not a function`.

The AsyncLocalStorage strategy is now only installed when no OpenTelemetry
strategy is installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cloudflare-keep-otel-async-context-strategy branch from 1e18758 to 7824cfc Compare October 5, 2026 09:13
@JPeer264

JPeer264 commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@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 7824cfc. Configure here.

@JPeer264 JPeer264 self-assigned this Oct 5, 2026
@JPeer264
JPeer264 marked this pull request as ready for review October 5, 2026 09:24
@JPeer264
JPeer264 requested a review from a team as a code owner October 5, 2026 09:24
@JPeer264
JPeer264 requested review from andreiborza, isaacs, mydea and nicohrubec and removed request for a team October 5, 2026 09:24

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