Skip to content
Latchkey

CI Test Suite Hangs and Is Killed

The test process stopped making progress until the runner killed it on timeout. The usual cause is an open handle or a test waiting on something that never resolves; sometimes a transient infra stall is to blame.

What this error means

Tests print output, then stop, and the step is eventually cancelled for timing out. A deterministic hang reproduces every run; a transient stall (slow service, blip) clears on re-run.

shell
PASS  src/a.test.ts
Jest did not exit one second after the test run completed.
##[error] The action has timed out.

Common causes

Open handles keep the process alive

Unclosed servers, DB connections, timers, or watchers prevent the runner from exiting, so it hangs until killed.

A test waits on something that never arrives

A missing mock, an unfulfilled promise, or a dependency that never becomes ready blocks forever.

How to fix it

Find the stuck test and open handles

Surface what keeps the process alive.

shell
jest --detectOpenHandles --runInBand --testTimeout=30000

Close resources and bound waits

  1. Close servers, DB pools, and timers in teardown.
  2. Add per-test timeouts so a stuck test fails fast.
  3. Ensure mocks/fixtures resolve so nothing waits forever.

How to prevent it

  • Run with --detectOpenHandles periodically.
  • Always tear down external resources.
  • When the hang is caused by a transient infra stall (e.g. a service slow to respond), managed runners detect the mechanical blip and automatically retry, so a one-off stall does not fail the build.

Frequently asked questions

What causes "Test suite hangs"?
Unclosed servers, DB connections, timers, or watchers prevent the runner from exiting, so it hangs until killed.
How do I fix Test suite hangs?
Surface what keeps the process alive.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card