Context
仮想ファイルツリー機能 (virtualTree.enabled = true) で起動するとき、commands/server.ts は以下のように loadResolverState を await する:
const resolverState = userConfig.virtualTree.enabled
? await loadResolverState(userConfig.documentRoot, userConfig.virtualTree.pathKey)
: null;
setRoute(app, userConfig, resolverState);
loadResolverState は frontmatter 不在 / pathKey 非文字列 / 論理パス重複の各ケースで throw する。runServerCommand 自体も async なので、throw は最終的に top-level await に伝播し、Node が uncaught exception として stack trace を吐いて exit code 1 で終了する。
Why this matters
ユーザに見える最も重要な UX のひとつ:
- 衝突メッセージの可読性:
PathConflictError.message は Conflicting logical paths in virtual tree:\n - "about.html" claimed by: 1.html, 2.html という構造化された複数行メッセージを持つが、Node のデフォルト uncaught handler は Error: プレフィックスと stack trace を一緒に出力する。ユーザにとって「最初の数行だけ読めば原因が分かる」状態になっているか保証されていない
- exit code が 1 であること: CI / プロセスマネージャ (PM2, systemd) がリトライ判断に使う
これらに対するテストがない(観点 5: ゴーストコード)。commands/server.ts から loadResolverState の呼び出しを消しても全テスト green。
Proposed approach
commands/server.spec.ts 新規:
documentRoot に重複した frontmatter.path を持つ html ファイルを 2 つ置く
runServerCommand を child_process.spawn で起動 (or vi.spyOn で process.exit を捕まえる)
- exit code 1
- stderr に
Conflicting logical paths と両ファイル名が含まれること
- もしくは
runServerCommand 内で明示的に try/catch して,PathConflictError のときは整形した message を console.error してから process.exit(1)。これなら stack trace が混じらず読みやすい。テストもシンプルになる
Out of scope of the parent PR
仮想ファイルツリー機能の本筋は完了。サーバー起動の失敗 UX 整備は別作業として切り出し。
References
Context
仮想ファイルツリー機能 (
virtualTree.enabled = true) で起動するとき、commands/server.tsは以下のようにloadResolverStateを await する:loadResolverStateは frontmatter 不在 / pathKey 非文字列 / 論理パス重複の各ケースで throw する。runServerCommand自体も async なので、throw は最終的に top-level await に伝播し、Node が uncaught exception として stack trace を吐いて exit code 1 で終了する。Why this matters
ユーザに見える最も重要な UX のひとつ:
PathConflictError.messageはConflicting logical paths in virtual tree:\n - "about.html" claimed by: 1.html, 2.htmlという構造化された複数行メッセージを持つが、Node のデフォルト uncaught handler はError:プレフィックスと stack trace を一緒に出力する。ユーザにとって「最初の数行だけ読めば原因が分かる」状態になっているか保証されていないこれらに対するテストがない(観点 5: ゴーストコード)。
commands/server.tsからloadResolverStateの呼び出しを消しても全テスト green。Proposed approach
commands/server.spec.ts新規:documentRootに重複した frontmatter.path を持つ html ファイルを 2 つ置くrunServerCommandをchild_process.spawnで起動 (orvi.spyOnでprocess.exitを捕まえる)Conflicting logical pathsと両ファイル名が含まれることrunServerCommand内で明示的に try/catch して,PathConflictErrorのときは整形した message をconsole.errorしてからprocess.exit(1)。これなら stack trace が混じらず読みやすい。テストもシンプルになるOut of scope of the parent PR
仮想ファイルツリー機能の本筋は完了。サーバー起動の失敗 UX 整備は別作業として切り出し。
References