Middleware exceptions escape the generated handleRequest and bypass configureServerErrors
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/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ệ
- typescript, vite
Hướng nghiên cứu
Start by reading src/ssr/index.ts around lines 1433-1453 and compare the server-function endpoint's handling of thrown Responses. Reproduce the production /boom case, then inspect src/node-entry/index.ts and the configureServerErrors path. Done means production middleware failures follow the stated response and error-policy behavior while dev retains its current overlay behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
In Start mode, the generated handleRequest runs the start.middleware chain without a catch:
When a middleware throws or rejects in a production build, the exception leaves handleRequest and each host deals with it in its own way:
- Nitro (h3) logs the original error with
console.errorand answers500with{"error":true,"status":500,"unhandled":true}as JSON. The headers and cookies the chain already wrote to the response stub are lost. start.nodelogs it and answers a plain-text 500 (src/node-entry/index.ts#L154-L161).- The
examples/start-ssrserver sendse.messageback to the client (examples/start-ssr/server.js#L78-L81).
Two consequences go beyond the inconsistent response:
- The hook registered with
configureServerErrors({ onError })never sees these failures, although its docs describe it as seeing "the failure that fails a request". Apps that rely on it to keep original errors out of logs, or to forward them to an APM (asstart.instrumentin #365 suggests), lose that for middleware, API handlers mounted in middleware, andstart.setup/start.renderModefailures. - A thrown control response turns into a 500.
return redirect('/login')from a middleware works, butthrow redirect('/login')reaches h3 as a non-Errorrejection and becomes an unhandled 500. The server-function endpoint, served by the same handler, already treats a thrownResponseas the response.
Reproduction
With @solidjs/vite-plugin 3.0.0-next.46, @solidjs/web 2.0.0-rc.11 and Nitro 3 beta:
// the module passed to start.middleware
export default async function middleware(request: Request, next: () => Promise<Response>) {
if (new URL(request.url).pathname === '/boom') throw new Error('token=abc123')
return next()
}
Build for production, serve it and request /boom: the response is Nitro's JSON 500, the server log shows Error: token=abc123 with its stack, and a hook registered with configureServerErrors is not called.
Expected
In production builds, the generated handler contains request failures the way the server-function endpoint does:
- a thrown
Response(exceptResponse.error()) or response envelope becomes the response; - anything else goes through the configured server error policy and yields a generic 500 that still carries the stub's headers and cookies;
- dev keeps the current behavior, so the Vite overlay still shows the original error.
Notes
- There is no public API today to run a value through the configured policy outside a render, so the handler would have to call the hook registered under the
configureServerErrorssymbol. A public entry point in@solidjs/webfor request failures, with its ownkindinServerErrorSite, would remove that coupling. - A later step could render the app's error boundary when the chain fails before the page render, so a failed navigation gets an HTML error page instead of an empty 500. Apps can do that in userland today, but it depends on the single-render rule and on excluding the server-function endpoint.
- Related: #328, since a deploy adapter would benefit from a handler that does not reject for application failures.
I'll follow up with a PR for the containment part.
- Ngôn ngữ chính
- TypeScript
- Star
- 522
- Fork
- 72
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 29
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 solidjs/solid-vite-plugin
-
Test environment detection doesn't consider Vitest workspacesCó thể đã có người làm @carloitaben đã nhận 47 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
solidjs/solid-vite-plugin#205 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
solidjs/solid-vite-plugin#396 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
solidjs/solid-vite-plugin#390 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
solidjs/solid-vite-plugin#388 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
solidjs/solid-vite-plugin#387 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid-vite-plugin
Issue tương tự
-
First unknown-user login after boot is one scrypt run slower than a real user's wrong passwordĐang mởarea: backend bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
snapotter-hq/SnapOtter#2254 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ticket
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cratestack/cratestack#1154 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
server 消息处理器 cmd 分支补显式错误回报——竞态非法命令现走未处理拒绝Có thể đã có người làm @openaddr đã nhận hôm nay. Đang mởready-for-agent refactor wayfinder:task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openaddr/dafung-web#428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrentlyĐang mởarea:testing bug effort:S priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
lens:agent lens:process process
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
thebristolsound/birdbrain#1772 ·
Maintainer thường phản hồi trong vòng 1 ngày