# Self-Healing CI: Recovering "Too Many Open Files" (ulimit)

> An EMFILE "too many open files" error is a file-descriptor limit, not a code bug. See the manual fix and how self-healing CI raises headroom and retries.

Source: https://latchkey.dev/learn/self-healing-ci/self-heal-too-many-open-files  
Updated: 2026-06-25

A "too many open files" failure means the job hit its file-descriptor ceiling - raising the limit or closing handles fixes it, no code change required.

## What makes a failure safely retryable

Automatic retry is only correct for failures that are genuinely transient. Retrying a deterministic failure wastes minutes and hides a real defect, so the classification matters more than the retry mechanism.

- Safe to retry: network timeouts, registry 5xx, transient DNS failures, a service container that was not ready, a spot instance reclaimed mid-run.
- Not safe to retry: assertion failures, compile errors, lint violations, anything that fails identically on every attempt.
- Ambiguous, and worth investigating rather than retrying: out-of-memory kills, disk exhaustion, and flaky tests. These repeat under load and a retry only hides the trend.
- Always record that a retry happened. A pipeline that silently retries is a pipeline whose real failure rate you do not know.

## FAQ

### What causes Self-Healing CI: recovering "Too many open Files" (ulimit)?

A step fails with EMFILE: too many open files or Too many open files while opening files, sockets, or watchers. The code is fine; the process exceeded the file-descriptor (ulimit -n) ceiling. A human raises the limit or reduces concurrency and the step passes unchanged.

### How do I fix Self-Healing CI: recovering "Too many open Files" (ulimit) manually?

[object Object]

### Can Self-Healing CI: recovering "Too many open Files" (ulimit) be fixed automatically?

An EMFILE has a clear descriptor-exhaustion signature, and the safe response is to provide headroom and retry. A self-healing CI pipeline detects the open-files limit condition, retries the step with an adequate descriptor limit, and only escalates if the exhaustion recurs - which would indicate a genuine descriptor leak rather than a

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
