Skip to content

outgoing-body flush behaviour states #811

Open

Description

@guybedford

As far as I can tell, outgoing-body's stream can exist in two different states:

  1. unattached to the http request, before the request is made - all writes buffer, and flush is effectively a no-op.
  2. attached to the outgoing http request after it has been made - in this state, flush functions correctly.

In state (1), does the subscribe just fail if we exceed the high watermark? Or is the high watermark functionality also disabled?

Effectively, does that mean that a transition from state (1) to state (2) change it from permitting writes over the high watermark to not?

Activity

  1. guybedford commented on Nov 23, 2023

    @guybedford
    ContributorAuthor

    The specific issue I hit here was that blocking-write-and-flush wasn't functioning correctly in this implementation due to the stream being unflushable before it has been attached to the http request.

  2. pchickey commented on Nov 27, 2023

    @pchickey
    Contributor

    Just discussed this with @elliottt -

    In case 1, we don't want to change the meaning of flush to mean nothing. Instead, calling flush should make the body stream not ready for writing until the request is sent successfully. A call to blocking-flush or blocking-write-and-flush would block forever, so in that case implementations should trap. (This is a particular special case where the wasi-http state of the body, as well as the state of the stream, would be required to determine that the implementation should trap, so we won't require it outright because that might be too difficult to implement in some cases - instead, those calls can hang forever, which is also correct but a worse DX.)

    One valid implementation of the body stream is permitting no buffering at all, so in state 1 it would never be write ready, and in state 2 it would only become write ready for whatever the underlying network layer buffers. That isn't a very realistic implementation, though, so we expect most implementations will permit some amount of buffering in both states 1 and 2, where once that buffering is full check-write returns 0 until the buffer is emptied. In state 1, either filling the buffer or calling flush will make the check-write return 0 until the body is sent and emptied, and in state 2 it would still need the network layer to empty it.

  3. guybedford commented on Nov 28, 2023

    @guybedford
    ContributorAuthor

    This sounds like a sensible direction and the right set of tradeoffs to make to me.

  4. added
    S-inactiveStatus: no discussion in over a year. Records silence during triage; not a proposal to close.
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-httpProposal: wasi-httpS-inactiveStatus: no discussion in over a year. Records silence during triage; not a proposal to close.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions