Start: server function ids naming Object.prototype members (constructor, __proto__) hit a TypeError in the resolver
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 85/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- node.js, typescript, vite
Rechercherichtung
Beginne in packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts bei der Manifest-Suche in getServerFnById; das Issue nennt die genaue Korrektur (Object.hasOwn). Wende dann in packages/start-plugin-core/src/vite/start-compiler-plugin/plugin.ts dieselbe Prüfung auf eigene Eigenschaften auf beide serverFnsById[fnId]-Guards an. Führe die Resolver- und Compiler-Tests von start-plugin-core aus. Fertig ist es, wenn IDs wie constructor, __proto__ und toString denselben Fehler 'Server function info not found for' werfen wie eine unbekannte ID, sowohl im generierten Resolver als auch im Dev-Server.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 15.3k
- Forks
- 1.9k
- Ø Merge
- 1 T. 5 Std.
- Gemergte PRs (30 T.)
- 46
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/router
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Evtl. vergeben @hassanabrar202 hat das vor 8 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Evtl. vergeben @Sheraff hat das vor 27 Tagen übernommen. Offenpackage: router-generator performance
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersEvtl. vergeben @Sheraff hat das vor 27 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
docs(router): clarify static title fallback in SPA modeEvtl. vergeben @Rohan-Dedhia hat das vor 17 Tagen übernommen. Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortErrorEvtl. vergeben @unjica hat das vor 29 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
TanStack/router#8776 · 3 Kommentare · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/router
Ähnliche Issues
-
Add: GTrekkerOffencheck:passed streams:add
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
area: ui Bug Payload OSS
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
payloadcms/payload#19839 ·
Maintainer antworten meist innerhalb von 1 Tag
-
external
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ClickHouse/ClickStack#3761 ·
Maintainer antworten meist innerhalb von 1 Tag
-
fix(auth): add the email OTP verification step to Pollar loginEvtl. vergeben @akansnoro hat das heute übernommen. OffenStellar Wave
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
safetrustcr/dApp-SafeTrust#584 · 10 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
The manager preset saves launch definitions without the required file and digest pairEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
Maintainer antworten meist innerhalb von 1 Tag