Skip to content

fix(vite): load server pages unpicked in server environments - #17

Open
brenelz wants to merge 1 commit into
mainfrom
fix/server-page-single-instance
Open

brenelz wants to merge 1 commit into
mainfrom
fix/server-page-single-instance

Conversation

@brenelz

@brenelz brenelz commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #16.

With serverComponents: true, the SSR environment loaded each server page twice. The manifest imported it as ?pick=default, and @solidjs/vite-plugin's server-function handler imported the plain file. Both instances called registerServerReference with the same id, and the second call replaced the first. The GET grant that @solidjs/router's query() makes was bound to the replaced function, so every client-side call to a server page returned 405.

In server-consumer environments, the Vite adapter now uses the plain id for every ref to a server page's file ($component, $$route, and any handler refs), in both the virtual module and the build inputs. The handler already loads that file whole, so a picked copy only added a second instance. Client environments still pick, so client bundles keep the stub and code splitting.

Verification:

  • pnpm test passes (114 tests). The new test in test/vite.spec.ts checks that the ssr manifest imports the server page without ?pick=, and it fails without the change.
  • I built a stories app (one server layout, two server pages, and a server action) against this branch's dist, with the local ?pick= workaround plugin removed. vite build now emits one registerServerReference per server page id instead of two. A Playwright run against the production server and vite dev navigated client-side to the server pages and submitted the form, and every /_server/data/... call returned 200. The same run against published 0.4.0 gets stuck on the first client navigation.

The third fix suggested in the issue, making a duplicate registerServerReference warn in @solidjs/web, is out of scope here.

🤖 Generated with Claude Code

The server-function handler imports a server page's file whole, so the
?pick=default copy was a second instance that registered the page's server
function twice. Fixes #16.
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.

Server pages load twice on the server (?pick=default and the plain file), so their data GETs return 405

1 participant