A red build gives you an exit code and a wall of output. The question that matters is simple: did the code break, or did the machine? The answer decides what you do next. Changing code to fix a full disk wastes time. Retrying a real test failure wastes more.
When coding agents run builds and tests for you, this question gets asked many times a day, and agents tend to assume the code is at fault. Sorting failures into a few classes stops that.
The classes, and how each one looks
Out of memory. The process or the machine ran out of memory. Signs: JavaScript heap out of memory, ENOMEM, or the word Killed with exit code 137 (signal 9 from the system's memory killer). Often appears when several builds or test suites run at once.
Disk full. Signs: ENOSPC or no space left on device. Build output, caches, container images and leftover temp folders fill a disk faster than people expect.
Too many open files. Signs: EMFILE, ENFILE or too many open files. File watchers and big test suites hit the per-process limit, especially on macOS where the default is low.
Port in use. Signs: EADDRINUSE or address already in use. A dev server or a test server from an earlier run, or from another agent, still holds the port.
Network. Signs: ECONNRESET, ETIMEDOUT, ENOTFOUND, EAI_AGAIN, ECONNREFUSED, socket hang up. A package registry, an API or a local service did not answer in time.
Time limit. Something stopped the run because it took too long. That can be your CI's job timeout or a limit you set.
Stopped by a signal. Someone or something ended the run: Ctrl-C, a closed terminal, a restart.
Test failure. The test runner's own summary: Tests: 3 failed, FAIL, 2 failing, --- FAIL, an assertion error. This is usually the code, or a flaky test.
Build error. A compiler or type checker error with a file and a line, such as error TS2322. This is the code.
How to sort a failure without any extra tool
- Note the exit code.
echo $?right after the run. 137 is a kill (signal 9), 143 a polite stop (signal 15), 130 a Ctrl-C. 1 and 2 are the program's own failure. - Search the output for the signs above, starting from the top. The first error is often the real one.
grep -n -E "ENOMEM|heap out of memory|ENOSPC|EMFILE|EADDRINUSE|ETIMEDOUT|ECONNRESET" build.logfinds most environment signs in one go. - Check the machine at that moment.
df -hfor disk, free memory and swap,uptimeagainst the core count for CPU, andlsof -i :<port>for ports. - Re-run once on a quiet machine, same commit. If it passes with no change, the cause was almost certainly the environment, or a flaky test. If it fails the same way, look at the code.
Doing this by hand works for one failure. It does not work for dozens a day across several agents.
How dotime-queue does the sorting
dotime-queue runs heavy commands through one waiting line on a computer and keeps a journal of every run. Each failed, stopped or timed-out run gets a reason class in that journal:
dotime-queue run --label "web-app: build" -- npm run build > build.log 2>&1dotime-queue reasonsThe classes are the ones above: memory, disk, files, port, network, run-limit, signal, test, build, and unknown when none fits. A test or build summary wins over an environment sign, so a test that fails because of a network error inside it still counts as a test failure, with the network sign noted beside it.
dotime-queue reasons counts the failures of the last 7 days by class, most first. For each class it shows how many failures began on a clean commit and how many of those passed on a plain re-run of the same commit. That last number tells you which classes were noise. --days <n> changes the range, and --json prints the same report as JSON.
Some things to know:
- The class is read from the run's output only when the output goes to a regular file, as in the example. Output to a terminal or a pipe is never read, and the failure is then
unknown. Only the class is kept, never the output. - A run cut off by a restart or a dead queue process is journalled as
lost. It is not a failure and counts in no class. - The reason only records. It changes no exit code and runs nothing again.
The queue also removes some of the causes. A job starts only when there is a free slot and the machine has room: by default at least 20 percent free memory and 10 GB free disk. A job that hangs is stopped at its run limit with exit 124.
What it does not do
- It does not fix the failure. It tells you which kind it was.
- It does not read errors from a cloud platform or a CI service. Only runs started through the queue on your machine are classed.
- It does not deploy anything by itself, and it does not host apps.
- A class is a sign, not a proof.
unknownmeans no fixed sign was found, not that the code is fine.