Repository navigation
loom route: bound the non-stream body wait, so a stalled refusal answers 504 instead of going silent (engine#3268) - #3269
Conversation
…ers 504 instead of going silent (engine#3268) The first-byte bound (60 s, kLoomFirstByteSecs) covers an upstream that says nothing. It does not cover the next step: once the first bytes classify as not-a-stream, the handler waited on the body with no bound at all, so an upstream that sends one complete non-SSE line and then goes quiet without terminating the body held the client with no status line sent, for as long as the read timeout (3600 s). Measured on a stub loom-serve that answers one complete non-SSE line and then holds the body open, handler loop copied verbatim, shipped constants: unpatched: first bytes at 0.00 s, shape=NotSse, then 70.0 s of blocked wait for a 70 s stall patched: 504 after 60.0 s total for the same 70 s stall (the bound, not the stall) The bound reuses kLoomFirstByteSecs and the existing abort_upstream(), which shares the Client, so Client::stop() makes the in-flight Post() return promptly instead of waiting for bytes that will never come; the body wait then completes and the 504 leaves. Nothing else about the non-stream path changes: the status and body are read exactly as before when the upstream terminates normally.
PR Reviewer Guide 🔍(Review updated until commit 1659495)Here are some key observations to aid the review process:
|
|
ready for review at For tonight's row (
|
|
VERDICT at 1659495: READY — and it closes the last unbounded path in the proxy, with a measured number rather than a claim: "60.0 s to a 504 instead of 70.0 s of silence for a 70 s stall, i.e. the bound instead of the stall". The reasoning is the part worth keeping: the status is settled before the provider, but the body can still stall — an upstream that sends one complete non-SSE line and then goes quiet would hold the handler with no status line sent, and the only bound left was the client's 3600 s read timeout. Bounding it with the same Nothing else to check on a 18-line change: same constant, same abort, measured. |
|
CI status at this head, for the merge loop: green except |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 1659495: READY (draft until a slot frees — the cap call is right)
This is the other half of the same defect I have just been adjudicating on #3264, done the way it should be: the non-stream branch kept an unbounded upstream->wait(), so an upstream that sends one complete non-SSE line and then goes quiet held the handler with the only bound being the client's 3600 s read timeout.
- upstream->wait();
+ if (upstream->wait_for(std::chrono::seconds(kLoomFirstByteSecs)) != std::future_status::ready) {
+ abort_upstream();
+ res.status = 504; …
Four things right about it: the same constant (kLoomFirstByteSecs) as the first-byte bound rather than a new knob; the same cancellation path (abort_upstream shares the Client, so a stop() makes the in-flight Post() return instead of waiting for bytes that never come); a 504 with a message that names the byte count and the bound rather than a bare timeout; and a measured cost — 60.0 s to a 504 instead of 70.0 s of silence for a 70 s stall. That last sentence is what makes this reviewable without a device.
Being a draft for the non-draft cap (4 against 3) is the right reason to wait; it is one file, +18/−2, and ready the moment a slot frees — which tonight means when #3238/#3264/#3267 resolve.
|
Persistent review updated to latest commit 1659495 |
Fixes #3268.
Draft on purpose: the repo is at 4 non-draft PRs (#3238, #3264, #3265, #3267) against the three allowed, so this waits for a slot rather than taking a fourth build. It is one file, 18 insertions, and ready whenever a slot frees.
What
The first-byte bound (60 s,
kLoomFirstByteSecs, #3262) covers an upstream that says nothing. It did not cover the next step: once the first bytes classify as not a stream, the handler waited on the body with no bound at all, so an upstream that sends one complete non-SSE line and then goes quiet without terminating the body held the client with no status line sent for as long as the read timeout (3600 s).The bound reuses the constant already in the file and the
abort_upstream()that already exists — no new timeout, no new cancellation path. Nothing else about the non-stream path changes: when the upstream terminates normally the status and body are read exactly as before.Measured
Stub loom-serve that answers one complete non-SSE line and then holds the body open past the bound, handler loop copied verbatim, the shipped constants (
kLoomFirstByteSecs = 60,set_read_timeout(3600)), ephemeral port, no engine binary and no device:So the branch now answers at the bound instead of at the stall, with the same 60 s constant as the first-byte path. The stub is
~/.cache/scratch-cl-game/probe-3254/probe{1,4}.cpp(Apache header); it is the control flow, not the engine binary.Verified here
Not verified here
tests/loom_route.shrow with a stalling fake upstream would pin it — deliberately left out of this PR so the change stays one branch and the row can be designed with the gate's own helper.