Route module load failure during client navigation reloads the current page instead of the navigation target
Reproduction
Framework mode, production build (react-router build), route /todos code-split into assets/todos-*.js.
- Load
/, which has<Link to="/todos">. - Make the first request for the
/todosroute chunk fail (dropped connection). Playwright:let blocked = 0; await page.route(/\/assets\/todos-[^/]+\.js$/, (route) => blocked++ === 0 ? route.abort("connectionreset") : route.continue(), ); await page.goto("http://localhost:8787/", { waitUntil: "networkidle" }); await page.locator('a[href="/todos"]').click(); loadRouteModulelogsError loading route module `/assets/todos-*.js`, reloading page...and callswindow.location.reload().
Result: exactly one document reload, and the page ends on /, not /todos. The retried chunk request would have succeeded, but the reload is for the location the user was leaving, so the user sees a flash and stays where they were. They have to click again.
With a permanently failing chunk the same code path reloads once and stops, so there is no loop; only the destination is lost.
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.5 LTS
Binaries:
Node: 22.23.0
Browsers:
Chrome: 142.0.7444.134
npmPackages:
@react-router/dev: 8.4.0
react-router: 8.4.0
vite: 8.3.1Used Package Manager
npm
Expected Behavior
When a route module fails to load during a client-side navigation, the recovery reload lands on the navigation's target location (for example, a hard navigation to the target URL instead of window.location.reload()), so a transient network failure costs one full page load rather than the navigation.
Actual Behavior
loadRouteModule (lib/dom/ssr/routeModules.ts) calls window.location.reload(). The navigation to /todos has not been committed yet, so the reload re-requests / and the navigation is dropped.
Context: a production app of ours sees this class of chunk-fetch failure regularly from mobile connections, proxies and content blockers (the asset still returns 200 on retry), so each occurrence currently costs the user a lost click.
Source: remix-run/react-router