Skip to content

Commit fb78a25

Browse files
test(cloudflare): ignore transaction envelope in double-instrumentation flake (#21095)
## Summary Fixes the flaky `suites/double-instrumentation/test.ts > Only sends one error event when withSentry is called twice` test in the Cloudflare Integration Tests job. ## Root cause When the worker throws on `/error`, two envelopes are produced inside the same request: 1. The `http.server` span ends (`startSpanManual` in `packages/cloudflare/src/request.ts`) → a **transaction** envelope is queued. 2. `captureException(...)` is called → an **event** envelope is queued. The Cloudflare transport buffers task producers in an `IsolatedPromiseBuffer` and drains them concurrently via `Promise.all` during `flushAndDispose`. Both envelopes are POSTed in parallel to the mock Sentry server, so the order in which they reach the test runner's `newEnvelope` callback is non-deterministic. The test only declares one expectation (the error event) and does not ignore transactions. When the transaction envelope happens to arrive first, the runner pops the expected event-envelope matcher and asserts it against the transaction payload — which mismatches on `type: 'event'` vs `type: 'transaction'` and rejects the run. Other tests that exercise the same path (e.g. `suites/hono-integration/test.ts`) handle this by expecting both envelopes with `.unordered()`. Here the test only asserts on the error event, so the smallest fix is to add `.ignore('transaction')` — matching the runner's existing default ignore list (`session`, `sessions`, `client_report`). The error-event shape assertions are unchanged. Fixes #21046 Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Jan Peer Stöcklmair <jan.peer@sentry.io>
1 parent a563b18 commit fb78a25

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • dev-packages/cloudflare-integration-tests/suites/double-instrumentation

dev-packages/cloudflare-integration-tests/suites/double-instrumentation/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ it('Only sends one error event when withSentry is called twice', async ({ signal
2626
},
2727
}),
2828
)
29+
// The http.server span produces a transaction envelope that is sent in parallel with the
30+
// error event. Either can arrive first at the mock server, so ignore it here to keep the
31+
// assertion focused on the error event.
32+
.ignore('transaction')
2933
.start(signal);
3034
await runner.makeRequest('get', '/error', { expectError: true });
3135
await runner.completed();

0 commit comments

Comments
 (0)