Repository navigation
fix: do not retry unit of work after it has committed - #47
Merged
Merged
Conversation
After commit callbacks are now executed outside the retry scope, so a failing callback no longer causes the committed unit of work to be re-attempted. All after commit callbacks are executed even if one fails; a single failure is rethrown, multiple failures are wrapped in the new AfterCommitCallbacksFailed exception. Closes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #46
Problem
UnitOfWorkManager::retry()caught exceptions thrown by after commit callbacks, which run after the unit of work has committed. This caused already-committed work to be re-executed, discarded or re-ran after commit callbacks, and hid the original exception behind the last attempt's failure.Changes
AfterCommitCallbacksFailedexception is thrown. It implements theApplicationExceptioncontract, exposesexceptions()(in the order thrown) and uses the first exception as its previous exception.ExceptionReporter, as they are not swallowed; they are thrown to the caller.Tests
Failing tests were added first, then the fix was applied:
it_does_not_retry_when_after_commit_callback_failsit_executes_all_after_commit_callbacks_when_several_fail(including callbacks registered by a failing callback)it_does_not_retry_after_commit_following_a_failed_attemptit_flushes_callbacks_when_after_commit_callback_failsAfterCommitCallbacksFailedTestcomposer allpasses.🤖 Generated with Claude Code