Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

util: `SuppressedError` should print `error`/`suppressed` properties during inspection

已關閉
#66,033 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
78/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript
領域
tooling

研究方向

從 lib/internal/util/inspect.js 中的 formatError() 開始,比較現有針對 cause 和 errors 的特殊處理。擴充檢查,讓 SuppressedError.error 和 SuppressedError.suppressed 以遞迴方式顯示,然後驗證 util.inspect() 和 console.log() 是否會為資源釋放錯誤產生所要求的巢狀輸出。

由索引模型根據 Issue 內容生成。

描述

feature request
What is the problem this feature will solve?

When a SuppressedError is thrown (e.g. from disposal errors during a using/await using block) and inspected via util.inspect() / console.log(), then the actual underlying errors (error and suppressed properties) are not shown:

class Resource {
  [Symbol.dispose]() {
    throw new Error('error during dispose');
  }
}
function test() {
  using res = new Resource();
  throw new Error('error during execution');
}
test();

Current output (Node v26.8.2):

SuppressedError: An error was suppressed during disposal.
    at test (REPL10:3:3)

Both those errors are essential for debugging.

This has the exact same shape as two problems Node already solved for other "container" errors:

AggregateError.errors was silently swallowed during inspection — fixed in #43646 (tracked in #43645).
Error.cause was silently swallowed during inspection — fixed in #41002 (tracked in #40859).

SuppressedError.error / SuppressedError.suppressed fall into the same category and currently have no equivalent handling in formatError() (lib/internal/util/inspect.js).

What is the feature you are proposing to solve the problem?

Extend formatError() so that, similar to how cause and errors are already special-cased, the non-enumerable error and suppressed properties of a SuppressedError are always included in the inspected output (recursively, since a SuppressedError can itself wrap another SuppressedError when multiple disposals fail).

Desired output, roughly matching what the cause-chain rendering already does:

SuppressedError: An error was suppressed during disposal.
    at test (…)
    ... {
  [error]: Error: error during dispose
      at Resource.[Symbol.dispose] (…)
      ...,
  [suppressed]: Error: error during execution
      at test (…)
      ...
}
What alternatives have you considered?
  • Manually logging e.error and e.suppressed in application code — works, but requires every catch block to know it might be dealing with a SuppressedError.
  • A userland [util.inspect.custom] patch on SuppressedError.prototype — works.

I believe a better out-of-the-box experience is required, rather than user-land patches. Workarounds shouldn't be necessary for a built-in error type tied to a TC39-standardized language feature

主要語言
JavaScript
星號
122k
分支
38.4k
平均合併
4 天 10 小時
30 天內合併 PR
276

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。