-
Notifications
You must be signed in to change notification settings - Fork 403
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
It is not possible to express a per-request Scope in a Handler that covers the entire request/response lifetime #3197
Comments
What scope do you want? You want the scope to be closed when the handler is done being used by the server? |
I think the correct solution here is:
To avoid breaking backward compatibility and avoid introducing overhead for "scope-less" handlers, this would have to be done very carefully using new methods / constructors. |
/bounty $500 |
💎 $500 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! Add a bounty • Share on socials
|
/attempt #3197
|
/attempt #3197 Options |
@987Nabil: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
@Ayush9026: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
If a Handler requires a Scope with a lifetime spanning all of request/response, it is not possible to express unless using a broader Scope that is not per-request.
An example case is:
Here we require a Scope for the handler. But we cannot
ZIO.scoped
within the handler as it would break the stream returned as a response. The other option is to have a higher level Scope that would not be per-request with instead the risk of leaking resources.Expected behaviour
A proper way to have a Handler provide a Scope for the request such as
Handler.scoped { }
to cover these cases.The text was updated successfully, but these errors were encountered: