Skip to content

test(cloudflare): Add E2E test that deploys a real Worker and sends to Sentry - #24280

Draft
JPeer264 wants to merge 1 commit into
jp/test-utils-sentry-cli-helpersfrom
jp/cloudflare-e2e-send-to-sentry
Draft

test(cloudflare): Add E2E test that deploys a real Worker and sends to Sentry#24280
JPeer264 wants to merge 1 commit into
jp/test-utils-sentry-cli-helpersfrom
jp/cloudflare-e2e-send-to-sentry

Conversation

@JPeer264

Copy link
Copy Markdown
Member

Adds cloudflare-workers-send-to-sentry, an optional E2E app that deploys a real Cloudflare Worker and verifies in Sentry that the SDK's data arrives, in the spirit of react-send-to-sentry. Local wrangler dev cannot reproduce what the platform does around waitUntil, isolate reuse, Durable Object hibernation and eviction. This app is the place for tests that need the real runtime.

The app is built with Vite, @cloudflare/vite-plugin and sentryCloudflareVitePlugin(), so the worker entry stays uninstrumented and the options live in src/instrument.server.ts via defineCloudflareOptions. Playwright's global setup deploys the Worker and waits for its workers.dev URL. The three tests cover a captured exception, an unhandled exception together with its request span, and a plain request span. They poll Sentry through @sentry-internal/test-utils/cli and log a paste-able sentry trace view command per trace.

Decisions:

  • One Worker per ref in CI, never deleted by the test run. Pull requests and merge-queue runs deploy to e2e-send-to-sentry-pr-<number>, pushes to e2e-send-to-sentry-<branch> (develop, master, v10). A run overwrites the Worker of its ref, so a failed run leaves its Worker in place for debugging, and Workers Logs are enabled for it. The new cleanup-e2e-workers.yml workflow deletes the PR Worker when the PR closes. The branch Workers stay. Local runs use a throwaway -local-<hex> name that the teardown deletes; E2E_KEEP_WORKER=1 keeps it.
  • Redeploying is always done, never skipped. A deploy takes about 10 s and the SDK tarball changes on almost every run.
  • The unhandled-error test sends baggage next to sentry-trace. The test has to pick the trace id itself, because a failed request cannot report ids. Without baggage the SDK freezes an empty dynamic sampling context (propagationContextFromHeaders in core, on purpose: "not head of trace"), and Relay drops the streamed span with the outcome missing_dsc. The error still arrives, only the request span is lost. This affects every server request whose upstream sends sentry-trace without baggage under span streaming and deserves its own issue.
  • Only CLOUDFLARE_ACCOUNT_ID is required by the setup. Wrangler authenticates with CLOUDFLARE_API_TOKEN in CI or a wrangler login session locally.

Repository setup: CLOUDFLARE_API_TOKEN (Workers Scripts: Edit, Workers KV Storage: Read) and CLOUDFLARE_ACCOUNT_ID point at the Sentry Dev account, and the optional E2E job passes both through.

Not in this PR: protecting the Worker URLs with Cloudflare Access and a service token. Worker-level Access rejects WebSocket upgrades, so it should be a hostname-based application per Worker, which needs "Access: Apps and Policies: Edit" on the API token.

Verified with real runs against the Sentry Dev account: all three tests pass in about 1.3 minutes, and the throwaway Worker is deleted afterwards.

Fixes #23610

🤖 Generated with Claude Code

…o Sentry

Local wrangler cannot reproduce what the platform does around waitUntil,
isolate reuse and Durable Object hibernation. The new optional E2E app
builds with the Sentry Vite plugin, deploys one Worker per ref in CI,
verifies errors and request spans in Sentry through the CLI helpers, and
deletes PR Workers through a new workflow when the PR closes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@JPeer264
JPeer264 added this pull request to stack #24281 September 10, 2026 06:29
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.81 kB added added
@sentry/browser - with treeshaking flags 27.12 kB added added
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB added added
@sentry/browser (incl. Tracing) 49.27 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 49.28 kB added added
@sentry/browser (incl. Tracing, Profiling) 52.21 kB added added
@sentry/browser (incl. Tracing, Replay) 88.81 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.99 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 93.49 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 106.44 kB added added
@sentry/browser (incl. Feedback) 46.3 kB added added
@sentry/browser (incl. sendFeedback) 33.87 kB added added
@sentry/browser (incl. FeedbackAsync) 38.99 kB added added
@sentry/browser (incl. Metrics) 29.84 kB added added
@sentry/browser (incl. Logs) 30.1 kB added added
@sentry/browser (incl. Metrics & Logs) 30.78 kB added added
@sentry/react 30.57 kB added added
@sentry/react (incl. Tracing) 51.64 kB added added
@sentry/vue 36.07 kB added added
@sentry/vue (incl. Tracing) 51.56 kB added added
@sentry/svelte 28.85 kB added added
CDN Bundle 30.56 kB added added
CDN Bundle (incl. Tracing) 49.81 kB added added
CDN Bundle (incl. Logs, Metrics) 32.83 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 51.77 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 73.48 kB added added
CDN Bundle (incl. Tracing, Replay) 87.35 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.26 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 93.28 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.27 kB added added
CDN Bundle - uncompressed 90.47 kB added added
CDN Bundle (incl. Tracing) - uncompressed 148.36 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.32 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.3 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.95 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.9 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.65 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.59 kB added added
@sentry/nextjs (client) 54.09 kB added added
@sentry/sveltekit (client) 49.73 kB added added
@sentry/core/server 36.99 kB added added
@sentry/core/browser 13.55 kB added added
@sentry/node 127.9 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.62 kB added added
@sentry/node - without tracing 88.73 kB added added
@sentry/node - without channel injection 107.14 kB added added
@sentry/aws-serverless 97.12 kB added added
@sentry/cloudflare (withSentry) - minified 202.05 kB added added
@sentry/cloudflare (withSentry) 502.91 kB added added

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.

Create E2E tests that use real Cloudflare Workers and send the data directly to Sentry

1 participant