Critical Bug Fix | Nested generated Distributed Event is not being published #22054
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.
Description
This pull request fixes a bug related to the publication of distributed events when they are generated in a nested manner during the completion of a
UnitOfWork
.Scenario in Which the Bug Occurs
Initiating a UnitOfWork: A new
UnitOfWork
is started.Appending Events: Both a Local Event and a Distributed Event are appended to the
UnitOfWork
.Completing the UnitOfWork: The
CompleteAsync
method is called on theUnitOfWork
.Handling the Local Event: The
ILocalEventHandler
for the local event is invoked.Nested Generation of a Distributed Event: During the execution of the
ILocalEventHandler
, a new Distributed Event is generated in a nested manner.Identified Issue
IUnitOfWorkEventPublisher
.UnitOfWork.CompleteAsync()
is not correctly handling this nestedly generated event.Checklist
How to Test It?
I have included a unit test in this pull request:
Volo.Abp.Uow.UnitOfWork_Event_Publisher_Tests
that tests this scenario. To observe the bug, simply run this test with the previous version ofUnitOfWork.cs
to see the issue occur.