-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove implicit forking in ZIO#onDone and ZIO#onDoneCause to align with onX methods #9286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@asr2003 These need tests to guarantee synchronous behavior for each. |
@jdegoes Sure! I will add it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asr2003 in addition to John's comment, can you please do the following:
- Add scaladoc to both
onDone
andonDoneCause
methods - Write a paragraph explaining the behaviour change of
onDone
which we will use in release notes. This should be similar to the "Important note about ZPool changes" found in the v2.1.10 notes
One last comment, I think the implementation should use |
@kyri-petrou @jdegoes Done with the changes! |
Co-authored-by: kyri-petrou <67301607+kyri-petrou@users.noreply.github.com>
Co-authored-by: kyri-petrou <67301607+kyri-petrou@users.noreply.github.com>
@kyri-petrou There has been type error if we use
So I have updated for the same to resolve this type mismatch |
Co-authored-by: kyri-petrou <67301607+kyri-petrou@users.noreply.github.com>
@kyri-petrou Done with the changes! |
Updated onDone and onDoneCause to execute callbacks synchronously on the main fiber to align behavior with other onX methods removing implicit forking( (i.e. NOT fork).
Closes #9191
/claim #9191
Important Note about Changes to
onDone
andonDoneCause
BehaviorIn this release, we have updated the behavior of
onDone
andonDoneCause
to address concerns raised in Issue #9191. Previously, these methods operated asynchronously by forking their callback effects, which could lead to subtle bugs and race conditions. This behavior was unique among ZIO'sonX
methods and diverged from typical expectations.Key Behavior Change: Synchronous Execution
Starting in this release,
onDone
andonDoneCause
now execute success and failure callbacks synchronously within the calling fiber. This update aligns them with otheronX
methods (e.g.,onExit
), ensuring that the effect completes fully, including any specified callbacks, before moving on. This change provides greater predictability and reliability by removing the previously implicit asynchronous behavior.Summary and Impact
This enhancement addresses the risk identified in Issue #9191, where the unexpected forking could cause surprising, hard-to-trace bugs. As a result, users may notice different callback behaviors following this upgrade. Where necessary, alternative patterns (such as explicit forking) can be employed to replicate prior behavior. We encourage users to review any code that relies on
onDone
oronDoneCause
and verify that the updated synchronous behavior aligns with expected outcomes.