Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kyri-petrou
Copy link
Contributor

/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 gracefulShutdownTimeout method on ZIOApp. 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 to Duration.Infinity in order to avoid breaking applications and to match the behaviour pre-2.1.17.

I'll followup with:

  1. Creating an issue to add tests for ensuring correct behaviour of ZIOApp
  2. Documenting gracefulShutdownTimeout

@kyri-petrou kyri-petrou requested a review from hearnadam May 29, 2025 09:22
@kyri-petrou kyri-petrou changed the title Fix awaing application finalizers Fix awaiting application finalizers to run on external interruption May 29, 2025
hearnadam
hearnadam previously approved these changes May 29, 2025
*/
def make[A]: OneShot[A] = new OneShot()

final class TimeoutException extends Error("Timed out waiting for variable to be set")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that the JS version does not have this same exception now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS version doesn't have a timeout so I guess that's fine?

@kyri-petrou kyri-petrou merged commit 29b3055 into zio:series/2.x May 30, 2025
18 checks passed
@kyri-petrou kyri-petrou deleted the fix-awaing-application-finalizers branch May 30, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZIO 2.1.18 does not wait on termination of registered finalizers

2 participants