Fix awaiting application finalizers to run on external interruption#9908
Merged
kyri-petrou merged 6 commits intozio:series/2.xfrom May 30, 2025
Merged
Conversation
hearnadam
previously approved these changes
May 29, 2025
core/jvm-native/src/main/scala/zio/ZIOAppPlatformSpecific.scala
Outdated
Show resolved
Hide resolved
Co-authored-by: Adam Hearn <[email protected]>
hearnadam
reviewed
May 29, 2025
| */ | ||
| def make[A]: OneShot[A] = new OneShot() | ||
|
|
||
| final class TimeoutException extends Error("Timed out waiting for variable to be set") |
Collaborator
There was a problem hiding this comment.
Just noting that the JS version does not have this same exception now.
Contributor
Author
There was a problem hiding this comment.
The JS version doesn't have a timeout so I guess that's fine?
hearnadam
approved these changes
May 29, 2025
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.
/fixes #9901
It seems that #9827 introduced a bug where finalizers might not run in applications that are exited externally. I'll create a release straight after this PR is merged because this can be a relatively severe bug. This should revert the behaviour to what was in 2.1.17 but without the bug that was fixed (#9807)
One other thing is that this PR adds the
gracefulShutdownTimeoutmethod onZIOApp. This way users can configure how much time the runtime will wait before exiting after an external interruption signal is received. This is partially to mitigate issues where the app might hang on termination (e.g., #5185) or because of uninterruptible finalizers that never complete. I set the default value toDuration.Infinityin order to avoid breaking applications and to match the behaviour pre-2.1.17.I'll followup with:
ZIOAppgracefulShutdownTimeout