A minifier moved one line and took production down for four days
The bug only existed in the production build, only on one code path, and the source was correct the whole time.
What happened
Object shorthand inside a call the bundler chose to inline survived relocation un-expanded. The deployed bundle then referenced a variable that no longer existed. It failed only in the production build, and only on the email path — so every local test passed and the error looked like a bad deploy.
What changed
We now reproduce in a production build before calling anything fixed, and grep the compiled chunks for the pattern rather than trusting the source. At known-risky call sites we write arguments out in full instead of using shorthand.
A client could not send their month-end pack. The error was a plain `ReferenceError` naming a variable that was, in the source, obviously defined two lines above the call that used it.
The first diagnosis was wrong. A deploy had gone out from a dirty working tree, so the obvious explanation was that the deployed code did not match the repository. It did match. The code was fine.
What actually happened is that the bundler decided to inline a small helper function at the call site. When it relocated the call, the object shorthand in the arguments — `{ periodStart, periodEnd }` — was carried across without being expanded to `{ periodStart: periodStart, periodEnd: periodEnd }`. In its new position the shorthand referenced locals that had been renamed by the minifier, so it resolved to nothing.
Three things made it hard to see. It only reproduced in a production build, so local development never showed it. It only affected the one code path that sent email, so most of the application worked. And a fix that appeared to work in the demo environment did not actually exercise that path at all, which produced a false all-clear and cost another day.
The fix was to write the arguments out in full at that call site, with a comment explaining why it must not be tidied back into shorthand. Anyone cleaning it up later would reintroduce the outage.
The wider lesson is about where you look. A production-only bug cannot be diagnosed from source, because the source is not what is running. Grepping the compiled chunk for the symbol took ten minutes and would have found it on day one.