How One Line of JavaScript Took My Entire Website Down for 11 Hours

https://hackernoon.imgix.net/images/3LZxQPDqVNfCiyYdlMIDfDqIUiQ2-2u82bx4.png

I build Candidate Falcon, a practice site for hiring assessments and one-way video interviews. At the start of November a release that added two new interview types reached production, and every page went blank. The login form didn't render, no button worked, and the console showed one error:

ReferenceError: Cannot access 'ko' before initialization

It stayed broken for about 11 hours, partly because our deploy checks said everything was fine. This post is about why one innocent-looking line caused it, and the two checks we added so it can't happen quietly again.

The setup: manual chunks

The app is built with Vite, and the Rollup output uses manualChunks to split the bundle by area of the site:

manualChunks(id) { const normalizedId = id.replace(/\\/g, '/'); if (normalizedId.includes('/node_modules/')) return 'vendor'; if (includesAny(normalizedId, ONE_WAY_CHUNK_MATCHERS)) return 'one-way'; if (includesAny(normalizedId, TIPS_CHUNK_MATCHERS)) return 'tips'; if (includesAny(normalizedId, HOME_CHUNK_MATCHERS)) return 'home';},

Everything under src/pages/prep/video-interviews/ goes into a...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more