Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#66,033 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
78/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu trong lib/internal/util/inspect.js tại formatError(), bằng cách so sánh cách xử lý đặc biệt hiện có đối với cause và errors. Mở rộng việc kiểm tra để SuppressedError.error và SuppressedError.suppressed xuất hiện đệ quy, sau đó xác minh rằng util.inspect() và console.log() tạo ra đầu ra lồng nhau được yêu cầu cho các lỗi giải phóng tài nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
276

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nodejs/node

Tất cả issue của nodejs/node

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.