Surface write failures through [flush]#217
Draft
dhouse-js wants to merge 4 commits intoinhabitedtype:masterfrom
Draft
Surface write failures through [flush]#217dhouse-js wants to merge 4 commits intoinhabitedtype:masterfrom
dhouse-js wants to merge 4 commits intoinhabitedtype:masterfrom
Conversation
ada2k
pushed a commit
to ada2k/ocaml-h1
that referenced
this pull request
Jul 31, 2024
Completes merge of inhabitedtype/httpaf#217 Co-authored-by: David House <dhouse@janestreet.com> Co-authored-by: Doug Patti <douglas.patti@gmail.com>
ada2k
pushed a commit
to ada2k/ocaml-h1
that referenced
this pull request
Jul 31, 2024
Completes merge of inhabitedtype/httpaf#217 Co-authored-by: David House <dhouse@janestreet.com> Co-authored-by: Doug Patti <douglas.patti@gmail.com>
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.
Currently, if you are writing to a body in a streaming manner, and the writer becomes closed, then you have to be careful to not write any more to the body. In practice this can be hard to achieve because your application-level code is probably the one writing to the body and your runtime / network-level code is the one that calls
report_write_result `Closed.This PR therefore makes it safe to write to a body after the attached writer is closed. Those writes are simply ignored.
The user has two ways of discovering whether their writes are actually going to be processed or not:
Body.is_closed, which now returns true if we've detected that the attached writer is closed, in addition to returning true ifBody.closedhas been called.Body.flushhas been augmented so that the callback is told whether the bytes successfully made it out of the writer, or were dropped on the floor. I.e. it has typeval Body.flush : Body.t -> ([ `Closed | `Written ] -> unit) -> unit.