Repository navigation
Description
Summary
decdn-node::probe_loopback probe_rate_limit_returns_rate_limited_close_code is flaky. It failed once on CI for an unrelated CLI-only PR (#1589) and passed on a plain re-run with no code change, which is the signature of a race rather than a regression.
Observed failure
Error: expected ApplicationClosed(16, "per-source"), got ApplicationClosed(ApplicationClose { error_code: 0, reason: b"" })
at crates/node/tests/probe_loopback.rs:794
Run: https://github.com/decdn/decdn/actions/runs/30907917266/job/91987351920 (attempt 1 test job; passed on attempt 2).
Diagnosis
The test drives a single probe connection that the server rejects at the per-source rate-limit layer on accept, and asserts on the client side that conn.closed() resolves to the application close ApplicationClosed(16 /* APP_ERR_RATE_LIMITED */, "per-source").
The rejection path closes the connection with the application close code + RejectReason::PerSource reason on the server. The client instead observed ApplicationClosed(error_code: 0, reason: b"") — a graceful/empty close. When the server rejects on accept and immediately tears the connection down, the client can resolve closed() from the transport-level teardown before (or instead of) the server's application CONNECTION_CLOSE frame carrying code 16 is delivered. Over loopback this ordering is timing-dependent, so it usually delivers code 16 but occasionally resolves as code 0.
The same failure mode plausibly affects the sibling test probe_three_layer_limiter_rejects_per_peer (crates/node/tests/probe_loopback.rs), which asserts the same way on the per-peer layer.
Fix direction (for whoever picks this up)
Options, roughly in order of preference:
- Make the server-side reject path flush/settle the application close before the connection is dropped, so the client is guaranteed to see code 16 rather than a transport teardown. Confirm the reject handler awaits the close frame being sent (e.g.
conn.close(...)then a drain/closed()on the server side) rather than returning and letting the connection drop. - If the graceful-close-before-app-close ordering is genuinely unavoidable at the QUIC layer, treat
ApplicationClosed(0, "")as an acceptable-but-weaker outcome and retry the observation, or assert with a bounded retry loop onclosed()— while still requiring the16 / "per-source"result to be reachable so the test keeps proving the reason-byte layering it exists to prove.
Whatever the fix, keep the assertion on the "per-source" / "per_peer" reason bytes: per the test comment, that is what distinguishes the per-source/per-peer layer firing from the also-0x10 global cap.
Repro
cargo nextest run -p decdn-node --test probe_loopback probe_rate_limit_returns_rate_limited_close_code --run-ignored all
# race; run in a loop to reproduce, e.g.
for i in $(seq 1 50); do cargo nextest run -p decdn-node probe_rate_limit_returns_rate_limited_close_code || break; doneMetadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
test(node): de-flake probe rate-limit reject close-code assertions (#…
test(node): de-flake the DHT integration suite and unpin two teardown…
test(node): de-flake the DHT integration suite and unpin two teardown…