feat(cloudflare): Only capture workflow step error on final retry attempt#21025
feat(cloudflare): Only capture workflow step error on final retry attempt#21025JPeer264 wants to merge 2 commits into
Conversation
|
|
||
| // Only capture error on final attempt (attempt > retryLimit means no more retries left) | ||
| // or when step context is unavailable (legacy behavior - capture all errors) | ||
| const isFinalAttempt = !hasStepContext || attempt > retryLimit; |
There was a problem hiding this comment.
note: On older versions this is not really the "final attempt", but treated as such, as there wouldn't be a good way of detecting it.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b3a7d57. Configure here.
b3a7d57 to
34f09ad
Compare
size-limit report 📦
|
timfish
left a comment
There was a problem hiding this comment.
There's no way to catch every exception? Might we want only capturing the last failure to be configurable?
Manual exceptions would still be send, only the But having it configurable would be nice, in case there is a use case I can't think of. I just wonder how this could look like as it would work only with a specific wrangler version and would noop in older versions (might be misleading I guess). Do you have something already in mind? |
I can't think of a nice way to add this as an option. I was just thinking that if a step errors for different reasons you'll only get the last one so some context might be lost. I guess most failures will be due to fetch failures or repetitive events anyway. |
Ah, no. That won't be the case. The following test actually checks if the actual errors are still getting send, but the actual step failure is only the last. With that, the user still gets 3 actual issues on these 3 attempts, but only 1 issue that the step failed: |
…empt 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 step context detection in `instrumentedCallback` - Add integration tests for step context behavior - Add e2e test for legacy behavior (wrangler 4.70.0) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
34f09ad to
ea2b9b2
Compare

closes #17421
closes JS-869
Cloudflare Workflows (wrangler 4.86.0+) now pass step context with
attemptandconfig.retries.limitto 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).
compatibility_datehas no effect withwrangler, so I couldn't make an integration test