Skip to content

Flaky anvil-e2e: forge script deploy subprocess hangs unbounded, freezing the test for minutes #785

Closed

Description

@thiras

Summary

The anvil-e2e CI job (cargo nextest run -p decdn-node --features anvil-e2e --test anvil_settlement_e2e) intermittently hangs for many minutes instead of completing in ~30s or failing cleanly. It usually passes, occasionally gets stuck. The stuck runs only end because the workflow's concurrency: cancel-in-progress (a later push) cancels them — they show as "cancelled", never a clean red ❌.

Root cause

The hang is the forge script DeployProtocol --broadcast subprocess in run_deploy_script (crates/node/tests/anvil_settlement_e2e.rs:869), invoked via blocking std::process::Command::output() with no timeout. forge script --broadcast intermittently stalls in its broadcast/receipt-wait phase against anvil (a known forge flake, more likely under shared-runner CPU contention). Because the subprocess call is unbounded — and the test has no overall timeout — one stall freezes the entire test.

Evidence

Both observed cancelled runs left forge and anvil alive as orphans at job teardown:

Terminate orphan process: pid (3071) (cargo-nextest)
Terminate orphan process: pid (3317) (anvil_settlement_e2e-…)
Terminate orphan process: pid (3382) (anvil)
Terminate orphan process: pid (3387) (forge)     <-- still running at cancel
  • Runs: 26836492907 (test step ran 17:25→17:38, 13 min) and 26825763092 (~8.5 min). Same orphan pattern in both.
  • Command::output() reaps the child on exit, so a still-listed, running forge means the test is blocked inside that call.
  • anvil is spawned after forge build and before forge script; it's alive too → the live forge is the deploy script, not the initial build.
  • Multi-minute duration rules out a poll_until timeout — every explicit wait in the test is bounded (poll_until ≤ 60s, stream_fetch 30s, shutdown-close 30s; epoch/expiry time is warped via evm_increaseTime, no real waiting). A poll_until miss returns Err and fails fast. Only an unbounded await explains 8–13 min.

Ruled out

  • Not the watcher/backfill race (#762).
  • Not the alloy filter poll interval (local 127.0.0.1 → 250ms).
  • Not a forge version mismatch — pinned v1.7.1 matches local, where the deploy runs in ~1s and the test is 12/12 green.

Why it doesn't reproduce locally

On a fast, uncontended machine with warm artifacts the deploy never stalls (12/12 passes at ~5s). The flake needs the contended CI runner — it is genuinely timing/external-tool-dependent.

Contributing factor

The anvil-e2e job has no timeout-minutes. Nothing bounds a hang except an unrelated cancel-in-progress from a later push; with no new push, a hung run would sit until GitHub's 6-hour default.

Proposed fix (smallest-first)

  1. CI guard rail — add timeout-minutes: 15 to the anvil-e2e job so a hang fails red quickly instead of squatting a runner / masquerading as "cancelled".
  2. Bound the forge subprocesses — run forge build / forge script via tokio::process::Command + tokio::time::timeout, kill the child on timeout, and retry the deploy 2–3×. Converts a rare forge stall into a brief retry instead of an unbounded hang. (Core fix.)
  3. Optional defense-in-depth — wrap the whole test body in an overall tokio::time::timeout so any future unbounded await (iroh, get_receipt) fails fast with a clear message.

References

Activity

  1. added
    kind:bug
    github_actions
    prio:high
    kind:test
    on Jun 2, 2026
  2. github-actions commented on Jun 2, 2026

    @github-actions

    🎯 Triage report

    The anvil-e2e CI job hangs 8–13 minutes when forge script --broadcast stalls under contended CI runners, because run_deploy_script calls std::process::Command::output() with no timeout. The job also lacks a timeout-minutes guard, so a hung run can squander a runner until GitHub's 6-hour ceiling or a cancel-in-progress intervenes — making it look "cancelled" rather than red. The reporter has already isolated the root cause with two concrete evidence runs and provides a clear 3-step fix.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug CI reliability regression with confirmed root cause and evidence
    Labels bug, testing, github_actions, high Affects test reliability and CI pipelines; high priority because flakes silently waste runner time and obscure real failures
    Coding agent Suitable Root cause pinpointed to specific file/line; three discrete, well-scoped fixes with no architectural ambiguity

    🔗 Similar issues

    💡 Notes and suggestions

    Suggested implementation order (smallest blast radius first):

    • 1. CI guard — .github/workflows/ci.yml anvil-e2e job: add timeout-minutes: 15. One-liner, zero Rust change, immediately makes hangs fail red.
    • 2. Bound forge subprocesses — in crates/node/tests/anvil_settlement_e2e.rs:
      • Replace std::process::Command::output() calls in run_deploy_script (~L869) and the initial forge build (~L246) with tokio::process::Command + tokio::time::timeout(Duration::from_secs(60), ...).
      • On timeout: kill the child (child.kill().await), retry up to 3×, then fail with a descriptive message.
      • This keeps the test async-native and is straightforward tokio usage.
    • 3. Optional overall test timeout — wrap the top-level test body in tokio::time::timeout(Duration::from_secs(120), async { ... }) as defence-in-depth against any future unbounded await.

    Anti-panic policy note: any unwrap()/expect() on the new tokio::process result must become proper ? propagation — the workspace denies unwrap_used and expect_used via clippy.

    forge flake context: forge script --broadcast receipt-polling is known to stall under CPU contention; the retry-with-timeout pattern (fix 2) is the standard mitigation used in similar foundry-rs CI setups.

    Generated by Agentic Triage for issue #785 · sonnet46 490.3K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

github_actionskind:bugkind:testprio:high

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions