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
Use Bracket
in the Http1Writer.write
#5565
Use Bracket
in the Http1Writer.write
#5565
Conversation
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.
In case of merging this, I'll port to the 0.23
as well (because of Bracket
to MonadCancel
rebranding).
85058f6
to
ff40852
Compare
body.drain.compile.drain.handleError { t2 => | ||
Http1Writer.logger.error(t2)("Error draining body") | ||
} | ||
} >> writeEntityBody(body) |
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.
Did we lose raising the error here?
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.
guaranteeCase
will pass further the raised error from the computing of FutureNoShift(F.delay(writeHeaders(headerWriter)))
with adding finally-computation body.drain.compile.drain
. If I'm correctly get it.
So what this effectively changes is that on cancellation we will drain the body. Are you sure that this is what we want? |
@RafalSumislawski could you please elaborate on the cases you are worrying about. I can't imagine cases of user cancellation of |
You're right. At the moment (current I'm not saying that we should deal with this in this PR, but just to explain myself: |
Are the problems that @RafalSumislawski is describing solved by the proposal of making a response a resource? Doesn't help for 0.22 or 0.23, of course. |
I was reminded about typelevel/cats-effect#1979 about the cancelation model in CE3 which culminated in: |
@rossabaker It provides a better alternative to using the @armanbilge I'm aware of this discussion. I ok with waiting for the deallocation of the resources, what I'm worried about is the streamy nature of the stream. Let's say we cancel sending a request/response which happens to be streamed from a 100GB file. Waiting for the file descriptor to be released sounds fine. Reading and discarding the 100GB sounds bad. |
@RafalSumislawski IIUC, on 0.22/0.23, the deallocation of resources is conflated with draining of the stream, which is something you might not want to wait for (or ideally do at all). Since we can only fix this with a |
@armanbilge |
A small enhancement. Semantics seems preserved.