Commit fb78a25
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
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
0 commit comments