field note 016 · 2026-08-15 · deploys, monitoring
a deploy script redeployed the same stale code 16,089 times, and the fix couldn't deploy itself
we run infrastructure for a blockchain data-indexing company. a fix we'd merged didn't show up in production, and that's how we found out three api boxes had been serving july 23 code for three weeks, rebuilding and reloading it once a minute, with every health check green.
the loop
each box runs a deploy script from cron every minute. it fetches, and if main has moved it pulls, runs npm i, builds, and does a pm2 reload. simple enough, and it had worked for a long time.
npm i is allowed to rewrite package-lock.json, and on a box that never commits, that rewrite just sits there. the next tick's git pull --ff-only refused to overwrite it. the script had no set -e, so it sailed past the failed pull and ran npm i again (re-dirtying the lockfile), built, and reloaded. same commit, every 60 seconds, indefinitely. one box's deploy log had the merge error in it 11,319 times and had grown to 16 MB.
why nobody noticed
every signal we had read healthy. the ping endpoint returned 200, the load balancer's health checks were green, pm2 said "online", and the deploy log ended on a clean npm run build. the one tell was cheap and nobody was looking at it: Starting API on port 8080 showed up in the logs 60, 62, and 62 times an hour on the three boxes. a healthy fleet restarts when it deploys and that's about it.
the fix for exactly this ("harden deploy-check against a dirty working tree") had been diagnosed on aug 4 and merged. it was one of the three commits stuck behind the freeze. a fix to the deploy path ships through the deploy path, so it sat there with everything else. we discarded the lockfile and pulled by hand on each box, once. the next cron tick did not reload.
then we broke it the other way
the hardened script added set -e and stashed box-local drift so it could never block a pull again. it also opened with a bare git fetch. these boxes reach the code host over ssh with a dedicated deploy key that isn't the default identity, and nothing pointed git at it. permission denied, set -e, abort on line 3. 600 of 600 consecutive cron runs did nothing, and the fleet sat on one commit for two days while main moved on.
the restart-rate check we'd built two days earlier was blind to it, because these boxes restarted never. and the one box we could ssh to without a cloud tunnel had a default key with repo access, so it deployed normally the whole time. spot-checking it proved nothing about the rest.