test(cloudflare): Add E2E test that deploys a real Worker and sends to Sentry - #24280
Draft
JPeer264 wants to merge 1 commit into
Draft
test(cloudflare): Add E2E test that deploys a real Worker and sends to Sentry#24280JPeer264 wants to merge 1 commit into
JPeer264 wants to merge 1 commit into
Conversation
…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
added this pull request to stack #24281
September 10, 2026 06:29
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofreact-send-to-sentry. Localwrangler devcannot reproduce what the platform does aroundwaitUntil, 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-pluginandsentryCloudflareVitePlugin(), so the worker entry stays uninstrumented and the options live insrc/instrument.server.tsviadefineCloudflareOptions. 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/cliand log a paste-ablesentry trace viewcommand per trace.Decisions:
e2e-send-to-sentry-pr-<number>, pushes toe2e-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 newcleanup-e2e-workers.ymlworkflow 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=1keeps it.baggagenext tosentry-trace. The test has to pick the trace id itself, because a failed request cannot report ids. Withoutbaggagethe SDK freezes an empty dynamic sampling context (propagationContextFromHeadersin core, on purpose: "not head of trace"), and Relay drops the streamed span with the outcomemissing_dsc. The error still arrives, only the request span is lost. This affects every server request whose upstream sendssentry-tracewithoutbaggageunder span streaming and deserves its own issue.CLOUDFLARE_ACCOUNT_IDis required by the setup. Wrangler authenticates withCLOUDFLARE_API_TOKENin CI or awrangler loginsession locally.Repository setup:
CLOUDFLARE_API_TOKEN(Workers Scripts: Edit, Workers KV Storage: Read) andCLOUDFLARE_ACCOUNT_IDpoint 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