OrderNot attempted
Recovering from a missing chunk
An old tab hits a chunk that a deploy removed, and the app has a guarded vite:preloadError handler. Order the steps.
Drag the rows, or use the arrows, to put them in order from first to last.
- The new entry code imports the chunk under its new name and the route renders
- The page reloads and the browser revalidates the HTML, getting the new version
- The handler finds no recent reload timestamp in sessionStorage, stores one and calls
event.preventDefault() - The import rejects and Vite dispatches
vite:preloadErroronwindow - The old entry code imports the chunk by its old hashed name and gets a 404
- The user clicks a link to a route they haven't opened yet
Show answer & explanation
Correct order:
- The user clicks a link to a route they haven't opened yet
- The old entry code imports the chunk by its old hashed name and gets a 404
- The import rejects and Vite dispatches
vite:preloadErroronwindow - The handler finds no recent reload timestamp in sessionStorage, stores one and calls
event.preventDefault() - The page reloads and the browser revalidates the HTML, getting the new version
- The new entry code imports the chunk under its new name and the route renders
A reload is the real fix because only the new HTML knows the new file names. preventDefault() stops the error from being thrown while the reload happens, and the stored timestamp stops a second reload if the new build fails the same way.