Skip to content

feat(1.x): reload once when a route chunk fails to load - #2349

Merged
brenelz merged 1 commit into
1.xfrom
feat/route-chunk-reload-1x
Oct 15, 2026
Merged

brenelz merged 1 commit into
1.xfrom
feat/route-chunk-reload-1x

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Closes #1644 on the 1.x line. Same change as #2348 on main.

When a deploy replaces a route's chunk while a page is open, navigating to that route fails to import its component. The page ends on "Error | Uncaught Client Exception" until the user refreshes by hand.

Change

  • lazyRoute's production branch wraps component.import() with withRouteChunkReload, in the browser only. The wrapper is the same as on main. On a failed import it checks a 10-second loop guard in sessionStorage, resolves with an empty component so the router finishes the navigation, and reloads once location.href is the destination. It falls back to reloading after 1 second. A second failure within the window is rethrown. feat(router): reload once when a route chunk fails to load #2348 explains why it resolves instead of staying pending.
  • A new reloadOnRouteChunkError option in defineConfig, on by default, passed to the client through define in all three routers, the same way as devOverlay. It is typed in config/index.d.ts and env.d.ts.
  • 1.x needs this inside lazyRoute rather than through Vite's vite:preloadError event. 1.x loads route components with a computed import(MANIFEST.client.inputs[...].output.path), which does not go through Vite's preload helper, so that event never fires for route chunks here. I checked this in a production build.

Testing

A real deploy on the 1.x basic fixture, production build. Build v1 and open /. Then stop the server, change about.tsx, build v2, restart on the same port, and click About in the open v1 tab:

Build Reloads Final URL Page
origin/1.x 0 /about "Error | Uncaught Client Exception"
this change 1 /about the v2 /about
this change, reloadOnRouteChunkError: false 0 /about "Error | Uncaught Client Exception"
this change, chunk still missing after the reload 1 /about no second reload
  • New route-chunk-reload.spec.ts (6 tests), the same as on main.
  • @solidjs/start test:ci (101 tests) and typecheck pass. apps/tests build, unit:ci and the full Cypress suite against the production build (19) pass.

🤖 Generated with Claude Code

When a deploy replaces a route's chunk while a page is open, navigating
to that route fails to import its component and ends on the error page
until the user refreshes by hand.

In production, wrap the route component import in lazyRoute. On failure,
resolve with an empty component so the router finishes the navigation,
then reload once the URL is the destination. A failure within 10
seconds of the last reload is rethrown, so a chunk that is still
missing shows the error instead of reloading in a loop. Add a
reloadOnRouteChunkError option, on by default, to turn it off.

Closes #1644.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 83e14e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2349

commit: 83e14e0

@brenelz
brenelz merged commit 95ca993 into 1.x Oct 15, 2026
7 checks passed
@brenelz
brenelz deleted the feat/route-chunk-reload-1x branch October 15, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants