File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,9 +22,12 @@ clearChunkReloadFlag();
2222// a chunk or its CSS/JS dependencies fail to load. We catch it here and reload
2323// the page so the browser fetches fresh HTML with the correct chunk references.
2424// See: https://vite.dev/guide/build.html#load-error-handling
25- window . addEventListener ( 'vite:preloadError' , event => {
26- // Prevent the error from propagating — we're handling it with a reload.
27- event . preventDefault ( ) ;
25+ window . addEventListener ( 'vite:preloadError' , ( ) => {
26+ // Don't call preventDefault() — that flips Vite into a silent branch where
27+ // the failed import resolves to `undefined`, causing downstream destructures
28+ // (e.g. lazy() callers) to throw a cryptic TypeError before the reload runs.
29+ // Letting the error propagate routes it through the unhandledrejection and
30+ // error-boundary handlers below, which also reload on isChunkLoadError.
2831 reloadOnChunkError ( ) ;
2932} ) ;
3033
You can’t perform that action at this time.
0 commit comments