Uh oh!
There was an error while loading. Please reload this page.
feat(response): the non-blocking dialect twins, and four defects they exposed (#177) - #192
Merged
Conversation
Contributor
CoverageTotal lines: 82.14% → 82.11% (-0.03 pp)
|
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Closes#177.
HttpResponse::trySseEvent()andtryWriteMessage()frame exactly whatsseEvent()andwriteMessage()frame and answer false on a full queue, having queued nothing andcommitted no header, so the same event or message can be offered again. Until now the
idiom was half-applied: a handler streaming SSE or gRPC had
tryWrite()in the API and noway to use it, because the framing lives inside the dialect call.
Both dialects share their formatting and their guards with the blocking twin — one helper
per dialect, and the entry points differ in the flag they pass to
append_chunk.Four defects the work exposed, fixed here
awaitWritable()was refused in SSE mode, so a handler refused bytrySseEvent()had nowhere to wait. Waiting emits nothing, so that guard and the buffered-body one now
apply to the calls that emit.
writeMessage()answered to neither guard. A gRPC frame could be pushed into atext/event-streambody, or silently discard a body set withsetBody(). It now goesthrough the same check as
write(), and so does the new twin.trySseEvent()started the stream before probing the peer, so its 499 landed on acommitted response and the handler could not answer with a status. It probes first.
awaitWritable($timeoutMs)documented a deadline no transport read. HTTP/2 nowwaits the shorter of the argument and the connection's write timeout.
Evidence
h1/031: HTTP/1 accepts every offer — it keeps no queue — and the record matchessseEvent()byte for byte, including the all-arguments-null no-op.h2/026: the ring fills, one refusal is taken and waited out, and the body is identicalto the blocking twin's — which is what proves a refusal queued nothing.
h2/027: the same for gRPC, alternating the two twins so the body also proves theyframe alike, five-byte prefix included.
h1/032: the peer aborts with a RST and both twins throwHttpException499 ratherthan answering false, on a response that is still uncommitted.
Also removes the
#179promise from three comments and the tryWrite docblock: themeasurement in #191 replaced it with a documented exception.