Skip to content

QuizNot attempted

The reload loop guard

Your vite:preloadError handler calls location.reload(). Why store a timestamp in sessionStorage and skip the reload if the last one was a few seconds ago?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • If the chunk is missing even in the new build (a broken deploy), each reload would fail again and reload forever
  • A reload fixes the normal case (new HTML → new chunk names).
  • If the new build itself is broken, the error repeats right after the reload, and without a guard the page reloads endlessly.
  • sessionStorage survives a reload in the same tab, so the next page load can see that it just tried and let the error reach an error boundary instead.
  • Not "browsers block reloads": they don't.
  • Not "form data": the timestamp saves nothing for the user.
  • Not "faster": it doesn't affect loading.