The tests are green on your laptop. The pipeline is red, or the deploy fails at the build step. You read the code and see nothing wrong. Usually that is because nothing is wrong with the code: the two runs were not the same run.
Most of the time the difference is in the environment. Sometimes it is the other way round: the local run that failed, or the local run you trusted, happened on a machine that was busy with other work. This page covers both.
The usual causes: the environment differs
Check these first. They explain most cases of "works here, fails there":
- Environment variables and secrets. A key or URL is set in your shell or a local
.envfile and missing on the build host. - Runtime versions. A different Node, Python or system library. Pin the version (
.nvmrc, theenginesfield, a.tool-versionsfile) and print it at the start of the pipeline. - Dependencies.
npm installon your machine may resolve other versions thannpm ciwith the lockfile on the build host. Commit the lockfile and use the same install command in both places. - Files that exist only on your machine. Ignored or untracked files, such as generated code, a local config or a build cache, make a local run pass that a fresh checkout fails.
git clean -ndxlists them without deleting anything. - Case-sensitive paths. macOS is case-insensitive by default, most Linux build hosts are not. An import of
./Buttonfor a file namedbutton.jsworks locally and fails on Linux. - State left from earlier runs. A local database already seeded, a cache already warm, a server already running. The pipeline starts from nothing.
- Resources on the build host. A smaller machine or container may run out of memory (exit 137) or time where your laptop did not.
How to diagnose it without any extra tool
- Reproduce from a fresh checkout. Clone the repository into a new folder, install with the same command the pipeline uses, and run the same test command:If it fails here, the difference was on your machine all along.Shell
git clone <your repo> fresh-checkcd fresh-checknpm cinpm test - Compare versions. Print
node --version,npm --versionand any tool the build uses, in both places. - Diff the environment. List the variable names (not values) your app reads and check each exists on the host.
- Run inside the same image. If the pipeline uses a container image, run the tests in that image locally.
- Read the first error, not the last. Pipelines often fail many steps after the real cause.
The other class: a busy machine
There is one more case, and it runs the other way. When several coding agents share one computer, a local run can fail because three test suites and a build ran at the same moment. The agent then reports red, and someone goes looking for a code problem that is not there. Or a "green" local result came from a quiet moment, and a later local check under load fails with timeouts.
You can spot this class by the error: timeouts, Killed, JavaScript heap out of memory, ENOSPC (disk full) or EMFILE (too many open files). Those are signs about the machine, not your logic.
How dotime-queue helps
dotime-queue runs heavy commands on one computer through a waiting line. Use it to make your local check equal to your deploy check, and to keep the machine from muddying the result.
- Run the same command the pipeline runs, through the queue.It waits for a free slot and for the machine to have memory, disk and CPU to spare, so the result is about the code.Shell
dotime-queue run --label "web-app: tests" -- npm test > test.log 2>&1 - Read the reason before you touch code. With the output in a file, each failed run gets a class:
memory,disk,files,port,network,test,build,run-limitand others.dotime-queue reasonscounts them for the last 7 days. A terminal or pipe is never read; those failures areunknown. - Check which commit passed.
dotime-queue passed --match "tests"prints astamp:line when a matching check passed on exactly this clean commit, and exits 1 when none did. - Ship from the same checks.
dotime-queue releaseruns the checks listed indotime.release.jsonon one commit, then a security check and the build, and only then your deploy command. See deploy only after the tests pass.
What it does not do
- It does not find or fix environment differences. Missing variables, other versions and case-sensitive paths are yours to fix.
- It does not run your CI pipeline or its workflow files, and it does not change your build host.
- It does not host apps or deploy to a cloud. A release runs the deploy command you write.
- It does not fix failing tests. It records why runs failed, so the real failures stand out.