My Entire Site 500’d, and the Build Was Green
DEV Community

My Entire Site 500’d, and the Build Was Green

My whole site went down on a green deploy. Every route, every API call, every cron job. The only clue in wrangler tail was this: ReferenceError: n is not defined n. One letter, in a method I had never touched. Next.js 16.3 added a second binding to a destructured declaration. The ast-grep patch OpenNext applies after the build was replacing that whole declaration and putting back only one of the names, while the code underneath kept reading the other one. In the minified chunks that serve real traffic, the first line of the method reads the deleted name and throws. In the unminified file it happened to work, because the name the patch put back was the name the guard read. That's why every build stayed green. The test snapshot had the orphaned variable in it the whole time. The test only compared strings, and a string can't throw a ReferenceError. I fixed it by replacing the whole method body instead of one declaration, and wrote tests that actually run the patched output. It merged into OpenNext, after a maintainer carried my PR into his. All I wanted was my site to be back up. Full trace: https://aashikbaruwal.com.np/blog/nextjs-16-3-composable-cache-referenceerror-fix/ Top comments (0)

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.