unwrapDatabaseError masks real DB errors with TypeError: Cannot convert object to primitive value

オープン 初心者向け
#798 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@elliotBraem がすでに取り組んでいます。

2026年11月6日 から。

  • #813 @elliotBraem による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend

調査の方向性

src/db/errors.ts の unwrapDatabaseError から始め、issue に示されている null プロトタイプの cause を再現してください。DatabaseError.message を読み取ってもエラーが発生せず、有用なメッセージが保持されることを確認し、その後、既存のエラーテストでカバレッジを確認してください。issue では、fiber-failure パスにおける cause プロトタイプの別個の調査も指摘されています。

索引モデルが issue の本文から書いたものです。

説明

Version: everything-dev 2.0.0-rc.39

unwrapDatabaseError (src/db/errors.ts:19) does String(error) for any cause that isn't an instanceof Error:

if (!(error instanceof Error)) return String(error);

When the cause is a non-Error object that has no primitive conversion (null-prototype object), String() throws TypeError: Cannot convert object to primitive value — and since this runs inside the DatabaseError.message getter, the TypeError replaces the real error everywhere .message is read (oRPC error serialization, vitest failure rendering, log lines).

Observed in CI: a PGlite failure surfaced as TypeError: Cannot convert object to primitive value with this stack, fully hiding the actual DatabaseError [stage=driver] message:

❯ unwrapDatabaseError everything-dev/src/db/errors.ts:19:40
❯ get message everything-dev/src/db/errors.ts:13:15
❯ get message every-plugin/src/runtime/errors.ts:12:16

Repro (node, using the shipped dist/db/errors.cjs):

const { DatabaseError } = require("everything-dev/db");
const dbErr = new DatabaseError({ stage: "driver", cause: Object.create(null) });
dbErr.message; // TypeError: Cannot convert object to primitive value

Additionally, somewhere between a layer-build failure (Effect.tryPromise passes the thrown Error through intact — verified) and usePlugin's rejection, the DatabaseError's cause is replaced by a null-prototype object, so this path is reachable in practice, not just contrived.

Suggested fix: make unwrapDatabaseError defensive for non-Error causes — try/catch around String(error), or a stringifyUnknown-style fallback (every-plugin's runtime/errors.ts already has one). Sibling fix worth investigating: why the fiber-failure path strips the cause's prototype before it reaches DatabaseError.message.

主要言語
TypeScript
スター
5
フォーク
4
平均マージ
9時間 44分
マージ済み PR(30日)
217

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NEARBuilders/everything-dev のほかの issue

NEARBuilders/everything-dev の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。