Start: server function ids naming Object.prototype members (constructor, __proto__) hit a TypeError in the resolver
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript, vite
Direzione di ricerca
Inizia da packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts, dalla ricerca nel manifest dentro getServerFnById; l'issue indica la correzione esatta (Object.hasOwn). Poi apri packages/start-plugin-core/src/vite/start-compiler-plugin/plugin.ts e applica lo stesso controllo di proprietà propria a entrambe le guardie serverFnsById[fnId]. Esegui i test del resolver e del compilatore di start-plugin-core. È fatto quando gli id come constructor, __proto__ e toString lanciano lo stesso errore 'Server function info not found for' di un id sconosciuto, sia nel resolver generato sia nel dev server.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which project does this relate to?
Start
Describe the bug
A server function request whose id names an Object.prototype member (constructor, __proto__, toString, hasOwnProperty, …) fails with a TypeError inside the resolver instead of the "not found" error an unknown id gets, so an app that answers unknown ids with a 404 (by catching Server function info not found for) still answers these with a 500.
The generated resolver looks the id up with a plain property read (packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts):
const manifest = { /* ids */ }
export async function getServerFnById(id, access) {
const serverFnInfo = manifest[id] // manifest['constructor'] === Object
if (!serverFnInfo) {
throw new Error('Server function info not found for ' + id)
}
// with includeClientReferencedCheck false (the Vite plugin when ssr is the provider)
const fnModule = serverFnInfo.module ?? (await serverFnInfo.importer())
// TypeError: serverFnInfo.importer is not a function
manifest is an object literal, so inherited members pass the !serverFnInfo check and the resolver throws a TypeError instead of its own "not found" error. Any client can send such an id, so stray or probing traffic turns into 500s and server errors.
The dev server has the same lookup in packages/start-plugin-core/src/vite/start-compiler-plugin/plugin.ts (if (fnId && serverFnsById[fnId]) and if (serverFnsById[fnId])), so a prototype id passes the "Invalid server function ID" guard there and fails later.
Complete minimal reproducer
No separate repository: it reproduces in any Start app built with the Vite plugin and default settings, with the request below. We confirmed it by importing the module generateServerFnResolverModule emits with includeClientReferencedCheck: false and calling getServerFnById('constructor'), which throws TypeError: serverFnInfo.importer is not a function where an unknown id throws Server function info not found for ….
Steps to Reproduce the Bug
- Build and start any Start app (
vite build, then run the server output). curl -i -X POST -H 'Sec-Fetch-Site: same-origin' http://localhost:3000/_serverFn/constructor- Compare with
curl -i -X POST -H 'Sec-Fetch-Site: same-origin' http://localhost:3000/_serverFn/no-such-id.
The server log for step 2 shows TypeError: serverFnInfo.importer is not a function; step 3 shows Server function info not found for no-such-id. __proto__ and toString behave like step 2, for GET and POST. In dev, the prototype id passes the Invalid server function ID guard and fails later with a different error.
Expected behavior
Every id the manifest does not own resolves like an unknown id. An own-property check fixes all four lookups; we run this as a local patch:
- const serverFnInfo = manifest[id]
+ const serverFnInfo = Object.hasOwn(manifest, id) ? manifest[id] : undefined
- if (fnId && serverFnsById[fnId]) {
+ if (fnId && Object.hasOwn(serverFnsById, fnId)) {
(and the same for the second serverFnsById[fnId] check in the dev-server plugin). The rsbuild path uses the same generator, so it is covered by the first change. A Object.create(null) manifest would work too.
Platform
@tanstack/start-plugin-core1.172.0 (also present onmaintoday)@tanstack/react-start1.169.7- Node 26.13.0, macOS and Linux
Additional context
With includeClientReferencedCheck: true the request fails earlier as "Server function not accessible from client", so only builds where that check is off (the Vite plugin when the ssr environment is the provider) reach the TypeError; the dev-server guard is affected either way.
- Lingua principale
- TypeScript
- Stelle
- 15.3k
- Fork
- 1.9k
- Merge medio
- 1g 5h
- PR unite (30g)
- 46
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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 TanStack/router
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Forse già presa @hassanabrar202 l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Forse già presa @Sheraff l’ha presa 27 giorni fa. Apertapackage: router-generator performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersForse già presa @Sheraff l’ha presa 27 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
docs(router): clarify static title fallback in SPA modeForse già presa @Rohan-Dedhia l’ha presa 17 giorni fa. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortErrorForse già presa @unjica l’ha presa 29 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
TanStack/router#8776 · 3 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/router
Issue simili
-
Add: GTrekkerApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
area: ui Bug Payload OSS
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
payloadcms/payload#19839 ·
I maintainer di solito rispondono entro 1 giorno
-
external
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ClickHouse/ClickStack#3761 ·
I maintainer di solito rispondono entro 1 giorno
-
fix(auth): add the email OTP verification step to Pollar loginForse già presa @akansnoro l’ha presa oggi. ApertaStellar Wave
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
safetrustcr/dApp-SafeTrust#584 · 10 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The manager preset saves launch definitions without the required file and digest pairForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno