Client navigation to a server route without a `search` schema throws: args carry `search: undefined`, which JSON arguments reject
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, nodejs, typescript
- Ambito
- backend-api-design, full-stack
Direzione di ricerca
Look at src/serverRouteShared.ts to see how serverRouteArgs always returns search: undefined. Understand the isJSONSafe check in @solidjs/web that rejects undefined. The fix likely involves modifying the router to omit the search key when no schema exists, or adjusting the serialization logic. Test by reproducing the bug with the provided example and verifying client navigation works after changes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
serverRouteArgs (src/serverRouteShared.ts) always returns { params, search }, and search is undefined when the route declares no search schema. On the client, @solidjs/web sends server function arguments as plain JSON by default. Its isJSONSafe check rejects undefined anywhere in the arguments, so the call throws before any request is made:
Server function arguments are sent as JSON by default and these arguments are not JSON-serializable. Call enableRichArguments() (from "@solidjs/web/server-functions/rich-args") once at startup ...
The route shows the error boundary instead of the page. Server rendering is not affected, because the server calls the function directly, so the first page load works and only client navigation fails. This covers every serverRouteComponent route and every file-system server page that has no search schema, which is the common case.
Your Example Website or App
The code below. I ran it as-is in a Vite start-mode app whose src/app.tsx renders <Router> inside <Loading>.
Steps to Reproduce the Bug or Issue
With @solidjs/router@2.0.0-next.28, @solidjs/web@2.0.0-rc.9 and @solidjs/vite-plugin@3.0.0-next.44 (start: {}, ssr: true, serverFunctions: { components: true }):
import { createRouter, defineRoute, query, serverRouteComponent } from "@solidjs/router";
const home = async () => {
"use server";
return () => <a href="/about">About</a>;
};
const about = async () => {
"use server";
return () => <p>About</p>;
};
export const Router = createRouter({
routes: [
defineRoute({ path: "/", component: serverRouteComponent(query(home, "home")) }),
defineRoute({ path: "/about", component: serverRouteComponent(query(about, "about")) })
]
});
- Load
/. It renders. - Click the "About" link.
- The client throws the error above, and no
/_server/data/...request is sent.
Calling enableRichArguments() at startup makes the navigation work, which confirms search: undefined is the only non-JSON value in the arguments.
Expected behavior
Navigating to a server route without a search schema should work with the default JSON argument encoding. The router could leave the search key out when there is no schema. A missing key and an explicit undefined look the same to the server function's destructuring, and the query key only needs the args to be stable. Alternatively, @solidjs/web's isJSONSafe could skip undefined object properties the way JSON.stringify does. The router seems like the smaller fix, since apps shouldn't need rich arguments just to use server routes.
Screenshots or Videos
None.
Platform
- OS: macOS 15 (Darwin 24.3.0)
- Browser: Chromium 149 (headless, Playwright)
- Versions:
@solidjs/router@2.0.0-next.28,@solidjs/web@2.0.0-rc.9,solid-js@2.0.0-rc.9,@solidjs/vite-plugin@3.0.0-next.44
Additional context
Using enableRichArguments() as a workaround currently runs into a separate @solidjs/web packaging bug in Vite builds (the rich-args import does not resolve under rolldown), so apps need a resolve alias as well.
- Lingua principale
- TypeScript
- Stelle
- 1.3k
- Fork
- 180
- Merge medio
- 1g 10h
- PR unite (30g)
- 19
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid-router
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
solidjs/solid-router#605 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
solidjs/solid-router#603 · 1 commento ·
-
<A> costs ~6us of server CPU per instance during SSR (20x a plain <a>), mostly mergeProps/splitProps Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
solidjs/solid-router#583 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
solidjs/solid-router#569 · 3 commenti ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
solidjs/solid-router#518 · 2 commenti ·
Tutte le issue di solidjs/solid-router
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bcgov/bc-wallet-mobile#4761 · 1 commento ·
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100