Skip to content

turnloop_websocket::Received has the same two undocumented zero cases as http1 and http2 Step #86

Description

@proggeramlug

turnloop_websocket::Received has the same two independent zero cases as http1::Step and http2::Step, and the same absence of any words about them.

  • consumed == 0 means "I need more input, wait".
  • consumed > 0 with no event means "progress was made, call me again" — the frame header of a message whose payload has not arrived, a control frame handled internally, a continuation.

A host that loops while "an event came back" stalls on the second case. A host that loops while "bytes were consumed" spins on the first. Neither is stated, and the type's shape does not distinguish them.

Why this one is worth doing on its own

This is the fourth instance of the same class in this crate:

PR #85 closes the observed class for turnloop-http: both its decoders now carry a stated contract with tests that fail when it is violated, including tests asserting that each wrong loop condition actually breaks. turnloop_websocket::Received is the same shape in a different crate and was not in that PR's scope.

What would fix it

Document both zero cases on Received, and add the same pair of tests turnloop-http now has: one proving a host that loops on "an event came back" stalls, and one proving a host that loops on "bytes were consumed" spins. A stated contract that nothing tests is how the previous three got shipped.

Worth checking receive's idempotence while there: the HTTP/2 work found that http2::Connection::receive is not idempotent, so a host that stalls and retries the same input fails the connection rather than making progress — a second-order trap that only appears once the first one bites.

Not this issue

A workspace-wide contract — one trait plus a turnloop-contract conformance suite across all four step-like types and the five database protocols that have no step type at all — is a larger, breaking change and deserves its own review. This issue is the single-type version, which needs no design settled.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions