Repository navigation
test(link): report the Child's HTTP relay waiting for its reader to a test-only observer - #8680
Merged
Merged
Conversation
…est-only observer
…der a stalled reader
… a stalled reader
…the Home fails unread
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
|
✅ Deterministic PR hygiene checks passed. |
lidge-jun
marked this pull request as ready for review
November 13, 2026 09:39
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
lidge-jun
added a commit
that referenced
this pull request
Nov 13, 2026
layout-clients.json and test-layout-expected.json: the union of both sides (link-relay-wait-observer.test.ts from #8680, link-ws-autobahn.test.ts from this branch), checked key by key; layout.json and structure/remote-link.md merged without conflict.
This was referenced Nov 13, 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.
Summary
The Child's memory acceptance (design 6.3) compares the Child's memory while its readers stall on the WebSocket and on HTTP. The Home already tells a test when each relayed HTTP response is waiting for its reader (
setLinkRelayWaitObserverForTests, #8600), so a load can wait until every reader has stalled before it reads the peak. The Child's HTTP relay (src/client/link-relay.ts) had no such signal, so the HTTP half of the Child's acceptance could not tell when its stall had begun.This adds the Child-side counterpart.
src/client/link-websocket-limits.tsgainssetLinkChildRelayWaitObserverForTests(observer)andlinkChildRelayWaitObserver(). Only while a test has set an observer,relayLinkDataRequestpasses each relayed response body (SSE and ordinary bodies alike) through a pass-through stream with a high-water mark of 0, so it reads only when its reader does. The observer is toldtrueafter a chunk is handed to the reader, andfalsewhen the reader asks for the next chunk, cancels, or when the relay itself ends. The relay's own cleanup (the Home's body finished or failed, a caller abort, the 300-second SSE idle limit) tellsfalseat once and suppresses every latertrue, so a relay that has ended is never counted as waiting. An observer that throws is ignored.structure/remote-link.mddescribes the Child's signal next to the Home's.The signal follows the relay's lifetime, as the Home's does. The relay streams underneath read one chunk ahead, so when the Home's body finishes, the relay can end (and report
false) while the reader still holds the last chunk; the relay holds nothing at that point. A Home failure that the relay has not read yet (its read-ahead chunk queued, nothing reading the Home) keeps it reported as waiting, because the relay still holds that chunk and its request until its next read, a caller abort or (for SSE) the idle limit ends it.What keeps it inert
No production code sets the observer, and it starts as
null. With no observer,relayLinkDataRequestpasses the same cleanup function and returns the same response body stream as before; the only added work is one null check per relayed response. No HTTP behaviour, byte counting, header, limit or cleanup path changes.Tests
tests/clients/link-relay-wait-observer.test.ts(new) relays throughrelayLinkDataRequestwith a stand-in fetch, an injected manual clock for the SSE idle limit, and a recorder whosenextFalse()settles on the firstfalseafter it is called. It never waits on a sleep, a real timer or polling; the relay's own 300-second header-deadline and SSE idle timers are armed on its default clock in seven of the eight cases and cleared before each case ends. It checks:[true], then[true, false, true], then[true, false, true, false]once the Home's body ends, with nothing more after the final readFailed first: with the two exports in place and
link-relay.tsunchanged, the original cases that expect events failed withexpected [true], received [](no events at all); the default case and the throwing-observer case pass without the change. Against the first version of the wrapper, which ended a wait only when the reader asked again, the stalled-reader cases (caller abort for JSON and SSE, the SSE idle limit) and the two step-by-step cases failed by the runner's timeout while waiting for thefalsethat marks the relay's end. With the fix, all 8 pass.Verification
bun run typecheck: exit 0bun run privacy:scan: exit 0bun run structure:check: exit 0TMPDIR=/tmp bun scripts/test.ts --parallel=2overlink-relay-wait-observer,client-link-relay,link-relay-bound-transport,client-link-tunnel,link-peer-compatibility,link-request-zstd,link-route-proof-relay,link-traffic,client-home-unreachableandlink-boundary(all undertests/clients/), plustests/test-layout.test.ts,tests/test-layout-tooling.test.ts,tests/ci-workflows/file-size-ratchet.test.ts,structure-ssot.test.tsandimport-cycle-ratchet.test.ts: exit 0, 289 pass, 1 skip (macOS only), 0 failNOT RUN: the full suite (resource limits on the build machine;
test changedand CI cover the rest), macOS and Windows.Checklist
scripts/test-layout/layout-clients.jsonandtests/fixtures/test-layout-expected.jsonstructure/remote-link.mdupdated for the owned area