Start: server function ids naming Object.prototype members (constructor, __proto__) hit a TypeError in the resolver
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript, vite
Hướng nghiên cứu
Bắt đầu từ packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts, tại chỗ tra cứu manifest bên trong getServerFnById; issue đưa ra cách sửa chính xác (Object.hasOwn). Sau đó mở packages/start-plugin-core/src/vite/start-compiler-plugin/plugin.ts và áp dụng cùng kiểm tra thuộc tính riêng cho cả hai điều kiện bảo vệ serverFnsById[fnId]. Chạy các bài kiểm tra resolver và compiler của start-plugin-core. Hoàn thành khi các id như constructor, __proto__ và toString ném cùng lỗi 'Server function info not found for' như một id không tồn tại, trong cả resolver được sinh ra lẫn dev server.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 15.3k
- Fork
- 1.9k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/router
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Có thể đã có người làm @hassanabrar202 đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Có thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mởpackage: router-generator performance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersCó thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(router): clarify static title fallback in SPA modeCó thể đã có người làm @Rohan-Dedhia đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortErrorCó thể đã có người làm @unjica đã nhận 29 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
TanStack/router#8776 · 3 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/router
Issue tương tự
-
Add: GTrekkerĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ui Bug Payload OSS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
payloadcms/payload#19839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
external
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ClickHouse/ClickStack#3761 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(auth): add the email OTP verification step to Pollar loginCó thể đã có người làm @akansnoro đã nhận hôm nay. Đang mởStellar Wave
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
safetrustcr/dApp-SafeTrust#584 · 10 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The manager preset saves launch definitions without the required file and digest pairCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày