Skip to content

test(http): drain the request in the provider stubs (issue #80 root cause) - #84

Merged
alderpath merged 2 commits into
mainfrom
fix/flake-80-rootcause
Nov 26, 2026
Merged

alderpath merged 2 commits into
mainfrom
fix/flake-80-rootcause

Conversation

@alderpath

Copy link
Copy Markdown
Collaborator

Fixes #80 at the root. The flake was in the test harness, not the product.

Root cause

All three provider stubs did a single stream.read(&mut buf) and then closed the socket. Under load the request arrives in more than one segment, so bytes stay unread in the receive queue. Closing a socket with unread receive data makes the kernel send RST instead of FIN, and the client surfaces that as:

provider stream <- provider stream: error decoding response body

That is why it was load-dependent (never in isolation, ~30% at 8-way concurrency) and why it looked like a hang: the durable session.error was written correctly, and my previous diagnostic reported session_errors=0 only because it queried the bare literal session.error while events are stored as session.error@v1. The diagnostic is fixed too.

Evidence

Same box, same 8-way concurrency:

binary failures
pre-fix 15 / 96
post-fix 0 / 96
post-fix (final) 0 / 120

Fix

drain_request reads until \r\n\r\n plus the declared Content-Length, so the close is a clean FIN. Applied to stall_gateway_data, stall_gateway (whose negative control could otherwise pass for the wrong reason) and free_tier_error. tests/stall.rs deliberately holds sockets without responding and needs nothing.

Also installs a tracing_subscriber in the test: without one, every tracing::error! on the failure path was invisible, so a failed turn and a hung turn were indistinguishable.

Test-only. No product code changed. Full workspace suite green (125 suites).

…ause)

Root cause, not a rerun. The three provider stubs read the socket once, then
closed it. Under load the request arrives in more than one segment, so bytes
stayed unread; closing a socket with unread receive data makes the kernel send
RST, and the client surfaces that mid-body as
`provider stream: error decoding response body`. The turn then failed with the
durable error already correct — the durable event was there all along, my
earlier diagnostic just queried the bare literal `session.error` while events
are stored as `session.error@v1`.

Evidence, same box, same concurrency, 8-way:
  pre-fix binary   15 / 96 runs failed
  post-fix binary   0 / 96 runs failed
  final binary      0 / 120 runs failed

`drain_request` reads to `\r\n\r\n` plus the declared Content-Length, so the
close is a FIN. Applied to `stall_gateway_data`, `stall_gateway` (whose
negative control could otherwise pass for the wrong reason) and
`free_tier_error`; `tests/stall.rs` holds sockets without responding and needs
nothing.

The test now also captures the code's own reason: a `tracing_subscriber` was
missing, so every `tracing::error!` on the failure path was invisible and a
failed turn was indistinguishable from a hung one.

Test-only; no product code changed.
`drain_request` brings its own `use std::io::Read`; the per-stub import lists
kept it and clippy -D warnings (CI runs --all-targets, my local run did not)
rejected it on all three platforms.
@alderpath
alderpath merged commit a78e360 into main Nov 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test flake: stall_gateway_data fails intermittently on main (2/4 synced runs)

1 participant