From bc092b6e8e91a99edf0223f67a40d28f205b6653 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 1 Sep 2026 13:53:01 +0200 Subject: [PATCH] test(cloudflare): De-flake Workflow auto-instrumentation test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scenario emits two transactions — the workflow `step-one` step and the `GET /workflow/trigger` request that triggers it — from separate executions, so which envelope reaches the mock server first is a race. The test expected a single envelope in ordered mode, asserting against whichever arrived first, and failed with `expected 'GET /workflow/trigger' to be 'step-one'` whenever the request transaction won. Expect both transactions with `unordered()`, matching what every other multi-transaction suite in `vite-autoinstrument` already does. This also covers the request transaction, which the test relied on the plugin producing but never asserted. Fixes #23242 Co-Authored-By: Claude Opus 5 (1M context) --- .../suites/vite-autoinstrument/workflow/test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/workflow/test.ts b/dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/workflow/test.ts index c942d5376132..f2771ae8f4f5 100644 --- a/dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/workflow/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/vite-autoinstrument/workflow/test.ts @@ -4,8 +4,12 @@ import { createRunner } from '../../../runner'; // The worker is built by the Sentry Vite plugin (auto-instrumentation on). The // runner detects `vite.config.mts`, runs `vite build`, and serves the generated -// output — so a workflow-step transaction only arrives if the build-time -// transform wrapped `MyWorkflow` with `instrumentWorkflowWithSentry`. +// output — so these transactions only arrive if the build-time transform wrapped +// `MyWorkflow` with `instrumentWorkflowWithSentry` and the default export with +// `withSentry`. +// +// The workflow step and the triggering request are separate executions whose +// envelopes race, so both are expected `unordered`. it('auto-instruments a Workflow class', async ({ signal }) => { const runner = createRunner(__dirname) .expect(envelope => { @@ -14,6 +18,13 @@ it('auto-instruments a Workflow class', async ({ signal }) => { expect(transactionEvent.contexts?.trace?.op).toBe('function'); expect(transactionEvent.contexts?.trace?.origin).toBe('auto.faas.cloudflare.workflow'); }) + .expect(envelope => { + const transactionEvent = envelope[1]?.[0]?.[1] as TransactionEvent; + expect(transactionEvent.transaction).toBe('GET /workflow/trigger'); + expect(transactionEvent.contexts?.trace?.op).toBe('http.server'); + expect(transactionEvent.contexts?.trace?.origin).toBe('auto.http.cloudflare'); + }) + .unordered() .start(signal); await runner.makeRequest('get', '/workflow/trigger');