SIGN IN SIGN UP

feat(cloudflare): Only capture workflow step error on final retry attempt (#21025)

closes #17421
closes
[JS-869](https://linear.app/getsentry/issue/JS-869/cloudflare-workflow-option-to-have-only-one-error-on-step-failure)

Cloudflare Workflows (wrangler 4.86.0+) now pass step context with
`attempt` and `config.retries.limit` to step callbacks. When available,
we use this to only capture errors on the final retry attempt, avoiding
duplicate error events during retries.

For older wrangler versions without step context, the SDK falls back to
legacy behavior (capturing errors on every attempt).

- Add integration tests for step context behavior
  - This is specifically for the new behavior
- Add e2e test for legacy behavior (wrangler 4.70.0)
  - This makes sure we won't break older wrangler versions
- This test breaks when wrangler is updated, as with a newer wrangler
version you get a higher compat version, therefore you get only 1 error
instead of 3
- A E2E test was chosen as it seem the `compatibility_date` has no
effect with `wrangler`, so I couldn't make an integration test

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
J
Jan Peer Stöcklmair committed
a438a0c8ac342f5e66408aabf24d651ba1deac23
Parent: 18fbbb7
Committed by GitHub <noreply@github.com> on 5/29/2026, 6:28:09 PM