Repository navigation
refactor(falcon): stop overriding private HTTP/1 writer and wrapper state - #82
Merged
Merged
Conversation
Owner
Author
|
@coderabbitai review |
Action not completed
|
…tate Anchor the retirement grace on the response body's clean close instead of the private `flush_stream`; protocol-http1 v0.37.1+ closes the body only after the final write and flush. Forward extra `write_body` arguments, and build `CompletionBody`'s final body before `super` instead of assigning the wrapper's `@body`. Refs #68
…path Cancellation can also close the body without an error, a bodyless response anchors when the writer returns, and the empty? branch now has its own flush-anchor case.
jimeh
force-pushed
the
refactor/falcon-public-api
branch
from
November 16, 2026 14:37
ed98a5a to
e1a0e4d
Compare
Owner
Author
|
@coderabbitai review |
Action performed
|
jimeh
marked this pull request as ready for review
November 16, 2026 14:47
This was referenced Nov 16, 2026
jimeh
added a commit
that referenced
this pull request
Nov 16, 2026
connectrpc-async's protocol-http1 and io-stream and connectrpc-falcon's protocol-http1 now follow the floor-and-cap policy, since #82, #83 and #85 removed their private coupling. async moves to >= 2.46.0, < 3 under a new guarded-coupling tier, justified by #88's require-time finalization probe. async-http and protocol-http2 stay patch-pinned, with their reasons in the gemspec and docs/development.md. The daily, non-gating canary workflow and canary:* tasks lift the remaining patch pins, run the Async and Falcon upstream contract specs and suites under wall-clock deadlines, and classify which contract broke. Refs #68
jimeh
added a commit
that referenced
this pull request
Nov 16, 2026
) * build: loosen freed socketry pins and add a pins-lifted canary lane connectrpc-async's protocol-http1 and io-stream and connectrpc-falcon's protocol-http1 now follow the floor-and-cap policy, since #82, #83 and #85 removed their private coupling. async moves to >= 2.46.0, < 3 under a new guarded-coupling tier, justified by #88's require-time finalization probe. async-http and protocol-http2 stay patch-pinned, with their reasons in the gemspec and docs/development.md. The daily, non-gating canary workflow and canary:* tasks lift the remaining patch pins, run the Async and Falcon upstream contract specs and suites under wall-clock deadlines, and classify which contract broke. Refs #68 * fix(canary): fail phases on leftover output holders and keep failure detail A phase whose command exits while a descendant still holds its output now stops reading after a short drain grace and fails, and one that exhausts its deadline while draining reports a timeout. The report script aborts with its reason instead of ending on a backtrace, and errors raised outside examples no longer hide the failed example ids. * fix(canary): attribute each hook error to its own hook Parse each RSpec hook-error block up to its own backtrace, so an expectation failure in one hook no longer borrows the error class of a later hook, and report a failed expectation by its first message line. * fix(canary): report a multiline hook expectation by its diagnostic RSpec prints a multiline source snippet before a failed expectation's diagnostic, so take the first line after the snippet's blank line. * fix(canary): keep quoted RSpec rerun ids in failure details RSpec reruns examples that share a location by id and quotes it unless the shell allows unquoted ids, so accept both forms. Also compare the canary's full scheduled time with CI's and check that a leftover descendant is gone after a drain timeout.
This was referenced Nov 16, 2026
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.
Change
This is item 1 of the plan in #68: the optional Falcon gem stops overriding private protocol-http1 methods and stops writing
Protocol::HTTP::Body::Wrapperstate. The goal is that the later item that loosens Falcon'sprotocol-http1pin (item 5) has no private touches left in this gem. Gemspec constraints are unchanged here. Intended behavior is unchanged.Final-flush anchor (
http1.rb). A successfully delivered response on a retiring HTTP/1 connection starts its single 500 ms close budget at the final flush, before body close callbacks such asrack.response_finished. That anchor used to come from an override of the privateProtocol::HTTP1::Connection#flush_stream, plus per-connection EOF state. It now comes fromHTTP1ResponseBody#close. The protocol-http1 v0.37.1 release note says the writer defersbody.closeinwrite_chunked_body,write_fixed_length_bodyandwrite_body_and_closeuntil the response is fully written and flushed. A close without an error, after EOF or for a HEAD response, therefore marks the final flush. The hook callsfinal_flushedonce and then closes the wrapped body, so callbacks still spend the same budget. A nil body goes throughwrite_empty_body, which flushes but has no body to close, sowrite_bodycallsfinal_flushedaftersuperreturns normally.write_bodyarity. The override now accepts and forwards extra positional arguments:(version, body, head = false, trailer = nil, *rest). protocol-http1 main adds a fifthrequestargument in socketry/protocol-http1#65, which is merged but not yet released.CompletionBody(rack_guard.rb). The Rack fallback's completion wrapper used to callsuperwith an empty buffered body and then assign@bodyafter converting the Rack tuple. It now converts first and passes the result tosuper. If the conversion raises, it releases in the same order asclose: completion callback, then the original body. One private helper now defines that order for both paths.docs/design.mdanddocs/streaming.mdnow describe the body-close anchor instead of an EOF marker paired with the next flush.typecheck/surface.jsondrops the removedflush_streamandeofentries, records the newwrite_bodyparameters, and classifiesHTTP1ResponseBody#initialize/#closeandCompletionBody#completeas internal.Decisions to review
rescue => errorcatches onlyStandardError. When cancellation (Async::Stop) interrupts the final flush after EOF, the writer still closes the body with a nil error, so the hook callsfinal_flushedalthough the flush did not finish. The old override did not. Nothing observable changes:write_bodyraises, the owner closes undelivered, and an undelivered close ignores grace and tears down raw-first. A new example pins that outcome. I chose not to check$!in the hook. A stale$!would skip grace on a delivered response and abort a connection that should have half-closed gracefully.write_body_and_closeflushes, then half-closes the write stream, then closes the body. Grace now starts after that half-close instead of at the flush, which is later by the time oneclose_writetakes. The other framing paths close the body right after the final flush. I accepted this rather than hook a private method again. After the final flush,close_writehas nothing left to flush (io-stream 0.14Writable#close_write). It then does a non-blockingshutdown(SHUT_WR), or for TLS oneSSL_shutdownthroughOpenSSL::SSL::SSLSocket#close_write, which does not wait for the peer. The path also needs an HTTP/1.0 response of unknown length on a retiring Connect streaming route, and HTTP/1.0 Connect streaming POSTs are refused with 505 (http1_corrections_spec.rb).*restcovers the positional argument that upstream adds. Adding**optionswould tripMetrics/ParameterListsfor a keyword signature that no upstream change proposes.Which specs pin the old guarantees
spec/http1_flush_spec.rb"anchors the pinned writer's final flush before callbacks" (chunked, fixed, zero length, absent body, HEAD fixed, HEAD chunked, HTTP/1.0) pins that the expiry equals the last flush plus 500 ms and is already set when body callbacks run.spec/http1_flush_spec.rb"never starts success grace after a failed final flush" pins that aStandardErrorduring the final flush leaves no grace and no half-close.spec/http1_flush_spec.rb"spends delayed callback and discard time within one total 500 ms budget" pins that callbacks and discard share one budget.spec/http1_flush_spec.rb"stays undelivered when cancellation interrupts the final flush" covers the cancellation case above, which the existing examples did not.{empty: true}row in the anchor matrix covers theempty?branch (unknown length,body.empty?true), which goes throughwrite_empty_bodyand now relies on the wrapper'sempty?EOF tracking. The fixture'sempty?was nil for every unknown-length row before.spec/fallback_spec.rb(streamed, callable, array and conversion-error Rack bodies, including cancellation inside a conversion-error callback) andspec/body_cleanup_spec.rbpinCompletionBody's callback and original-close order.Refs #68. This does not close it; the plan has six items.
Verification
On
4f5654a(Ruby 3.4.12):mise run falcon:verifypassed, includingfalcon:test395 examples with 0 failures,falcon:interop,falcon:interop:grpc(h2c, TLS, mTLS, keepalive age drain) andfalcon:package.On
2c9c8dd, which changes only docs and the flush spec:spec/http1_flush_spec.rbhas 11 examples and 0 failures. With the wrapper'sempty?EOF tracking removed, the new{empty: true}row fails atexpect(@close_expires).to eq(flush_at + 0.5)(expected 10.5, got nil); restored and green.falcon:checkandcheck:staticreport no offenses.On
ed98a5a, which changes onlytypecheck/surface.json:mise run rbs:checkpassed (109 files inventoried; public API consumers and the Falcon fallback consumers passed).Before rebasing onto #78, which adds only
docs/plans/interceptors.md:mise run falcon:test -- spec/http1_flush_spec.rb: 10 examples, 0 failures, including the new example by name.write_body's ensure callinginput_retirement&.close(true)instead ofclose(!!written), the new example fails atexpect(events).not_to include([:shutdown, Socket::SHUT_WR]). Restored and green again.mise run falcon:test -- spec/fallback_spec.rb spec/body_cleanup_spec.rb: 21 examples, 0 failures.mise run falcon:test: 395 examples, 0 failures.mise run falcon:check,mise run check:static: no offenses.mise run falcon:interop: all pass (h2c, TLS and mTLS, both codecs).mise run falcon:conformance:http1: 160 of 160.Written on behalf of jimeh by
claude-opus-5-5usingClaude CodeviaT3 Code.