Skip to content
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

Scope finalizers don't run on runtime shutdown #131

Open
kciesielski opened this issue Apr 29, 2024 · 0 comments
Open

Scope finalizers don't run on runtime shutdown #131

kciesielski opened this issue Apr 29, 2024 · 0 comments

Comments

@kciesielski
Copy link
Member

Ox offers a nice way to manage resources in scopes:

supervised {
  val serverBinding = useInScope(NettySyncServer().addEndpoints(endpoints).start())(_.stop())
  //...
  never
}

The release clause (_.stop()) is run only if the scope fails due to an unhandled exception. We often deal with long-living resources which should get released on server shutdown, which typically means a TERM signal to the JVM, handled by a shutdown hook.
This is handled in Cats Effect by IOApp, where users can compose resources into a final effectIO[ExitCode]. In case of runtime shutdown,main fiber will be canceled and resource finalizers will be called.
Maybe we can somehow achieve a similar effect in Ox? There is no notion of App, main fiber etc., but I'm leaving this issue as a remark that using resources in scopes has this particular limitation.

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

No branches or pull requests

1 participant