You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(node): probe_rate_limit_returns_rate_limited_close_code flakes under nextest #691
kind:bugSomething does not behave as documentedkind:testTest coverage, flakes, fixtures or the e2e harnessrustDependabot: a Cargo update; use area: labels for Rust code otherwise
Surfaced during PR #684 verification: the test probe_rate_limit_returns_rate_limited_close_code flakes under cargo nextest run but passes reliably under cargo test. The failure is unrelated to the contract changes in #684, so it was not addressed there.
Repro
cargo nextest run -p decdn-node probe_rate_limit_returns_rate_limited_close_code
Compare against:
cargo test -p decdn-node probe_rate_limit_returns_rate_limited_close_code
Likely cause: nextest's per-test process isolation interacts with the dispatch rate limiter's wall-clock window in a way that the in-process test runner does not. Suspects to investigate:
Test relies on a real time interval and nextest's startup overhead pushes the assertion past the window edge.
Shared global state (e.g. a static limiter cell) initialized at a different point in the two harnesses.
A tokio::time::pause/advance boundary that fires before the rate-limit check.
Acceptance
Test passes reliably under both cargo nextest run and cargo test.
If the fix is to fake the clock, use tokio::time::pause consistently across the rate-limit test surface so no other test in the same file regresses.
A test for the dispatch rate limiter is flaky exclusively under cargo nextest (per-process isolation) but passes under cargo test. The issue is well-scoped: the author identified three concrete suspects (wall-clock window edge, static state init timing, tokio::time boundary) and provided clear acceptance criteria. Surfaced as a side-effect of PR #684 verification, so it's not blocking that PR but is a CI reliability concern.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
A test that passes under one harness but fails under another is a test reliability defect
Labels
bug, rust, testing (already applied)
All three pre-existing labels are correct; medium priority would be appropriate as it affects CI reliability but isn't blocking
Coding agent
Suitable
Requirements are precise, repro commands are provided, acceptance criteria are well-defined, scope is fully self-contained within crates/node
💡 Notes and suggestions
Root cause investigation order:
Check for wall-clock dependency first — search the test for std::time::Instant, Duration::from_millis, or sleep. Any real-time sleep in a nextest environment is inherently flaky because nextest spins up a fresh process (with its own tokio runtime) per test, adding startup jitter.
Check for static or once_cell rate limiter state — if the limiter is held in a static LazyLock<...> or similar, it is initialized fresh per-process under nextest (correct) but may carry state from a prior test under cargo test in-process. This could explain why cargo testalways passes — a prior test may have reset the window.
tokio::time::pause / advance audit — if any other test in the same file calls tokio::time::pause and the probe test runs after it under cargo test (but before it under nextest due to ordering), the clock state differs.
Recommended fix pattern:
#[tokio::test]asyncfnprobe_rate_limit_returns_rate_limited_close_code(){
tokio::time::pause();// freeze wall clock// ... set up limiter with a known window ...
tokio::time::advance(window_duration + margin).await;// ... assert rate-limited close code ...}
Use tokio::time::pause() + advance() consistently across all rate-limit tests in the file, as the issue author notes. This eliminates real-time dependency entirely.
Sub-task checklist:
Locate the test in crates/node/src/ (likely dispatch.rs or a tests/ submodule)
Audit all time dependencies in the test (real Instant, sleep, Duration)
Replace wall-clock usage with tokio::time::pause + advance
Confirm no other test in the same file breaks (run cargo nextest run -p decdn-node for the full file)
Verify both cargo nextest run and cargo test pass reliably
kind:bugSomething does not behave as documentedkind:testTest coverage, flakes, fixtures or the e2e harnessrustDependabot: a Cargo update; use area: labels for Rust code otherwise
Activity
github-actions commentedon May 28, 2026
🎯 Triage report
A test for the dispatch rate limiter is flaky exclusively under
cargo nextest(per-process isolation) but passes undercargo test. The issue is well-scoped: the author identified three concrete suspects (wall-clock window edge, static state init timing,tokio::timeboundary) and provided clear acceptance criteria. Surfaced as a side-effect of PR #684 verification, so it's not blocking that PR but is a CI reliability concern.📊 Assessment
bug,rust,testing(already applied)mediumpriority would be appropriate as it affects CI reliability but isn't blockingcrates/node💡 Notes and suggestions
Root cause investigation order:
Check for wall-clock dependency first — search the test for
std::time::Instant,Duration::from_millis, orsleep. Any real-time sleep in a nextest environment is inherently flaky because nextest spins up a fresh process (with its own tokio runtime) per test, adding startup jitter.Check for
staticoronce_cellrate limiter state — if the limiter is held in astatic LazyLock<...>or similar, it is initialized fresh per-process under nextest (correct) but may carry state from a prior test undercargo testin-process. This could explain whycargo testalways passes — a prior test may have reset the window.tokio::time::pause/advanceaudit — if any other test in the same file callstokio::time::pauseand the probe test runs after it undercargo test(but before it under nextest due to ordering), the clock state differs.Recommended fix pattern:
Use
tokio::time::pause()+advance()consistently across all rate-limit tests in the file, as the issue author notes. This eliminates real-time dependency entirely.Sub-task checklist:
crates/node/src/(likelydispatch.rsor atests/submodule)Instant,sleep,Duration)tokio::time::pause+advancecargo nextest run -p decdn-nodefor the full file)cargo nextest runandcargo testpass reliablyAdd this agentic workflows to your repo
To install this agentic workflow, run
test(node): de-flake probe rate-limit close-code test (#691) (#696)
test(node): de-flake the DHT integration suite and unpin two teardown…
test(node): de-flake the DHT integration suite and unpin two teardown…