Middleware exceptions escape the generated handleRequest and bypass configureServerErrors
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, vite
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 522
- フォーク
- 72
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 31
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid-vite-plugin のほかの issue
-
Test environment detection doesn't consider Vitest workspaces対応中かも @carloitaben が 43 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
solidjs/solid-vite-plugin#205 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 65/100
solidjs/solid-vite-plugin#394 ·
メンテナーはふだん 1 日以内に返信
-
Catch-all route chunks are named `_...404_-<hash>.js`; the `..` trips path-traversal guards and breaks the lazy preload対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
solidjs/solid-vite-plugin#391 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
solidjs/solid-vite-plugin#390 ·
メンテナーはふだん 1 日以内に返信
-
Start mode: generated entries render without the CSP nonce, and there is no per-request seam to supply one対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
solidjs/solid-vite-plugin#388 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
solidjs/solid-vite-plugin の issue をすべて見る
似ている issue
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
lingdojo/kana-dojo#31665 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
Bug: lockTtlSeconds / lockHeartbeatIntervalSeconds accept non-positive and non-finite values対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CopilotKit/CopilotKit#7618 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sleeyax/paseo-plugins#112 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 4 日以内に返信