Rust "cargo nextest" Failures - Leaked/Timed-Out Tests in CI
A cargo nextest run had at least one test that failed, leaked a child process, or exceeded its slow/leak timeout and was aborted. nextest runs each test in its own process, so its failure modes (LEAK, slow, timeout) differ from the built-in harness.
What this error means
nextest prints a summary with FAIL, LEAK, or TIMEOUT/ABORT lines and exits non-zero. A LEAK means the test passed but left a child process or open handle; a slow/timeout abort means it ran past the configured limit.
FAIL [ 0.012s] app::math tests::divides
LEAK [ 5.030s] app::net tests::spawns_server
------------
Summary [ 5.1s] 24 tests run: 22 passed, 1 failed, 1 leaked
error: test run failedCommon causes
A test assertion failed
Like the built-in harness, a FAIL line is a genuine failing test - an assertion didn’t hold or the test panicked. It reproduces on the same code.
A leaked process or a slow/timeout abort
nextest flags a LEAK when a test leaves a child process or handle open after returning, and aborts tests that exceed the slow-timeout/leak-timeout. A test spawning a server without cleaning it up is the classic leak.
How to fix it
Read the summary and reproduce the failure
- Identify each
FAIL/LEAK/TIMEOUTline and the test it names. - Re-run just that test with a filter expression, e.g.
cargo nextest run -E "test(divides)". - For a LEAK, ensure the test joins/kills any process or task it spawns before returning.
Tune timeouts deliberately, not to mask bugs
Raise the slow/leak timeout only for genuinely long tests; don’t use it to hide a hang or a leak.
# .config/nextest.toml
[profile.ci]
slow-timeout = { period = "60s", terminate-after = 2 }
leak-timeout = "1s"How to prevent it
- Clean up spawned processes/tasks in tests so they don’t leak.
- Keep per-test timeouts tight enough to catch hangs but generous for real long tests.
- Run
cargo nextest runlocally before pushing.