Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen
#66,033 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
78/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
tooling

Rechercherichtung

Beginne in lib/internal/util/inspect.js bei formatError() und vergleiche die bestehende Sonderbehandlung für cause und errors. Erweitere die Inspektion so, dass SuppressedError.error und SuppressedError.suppressed rekursiv angezeigt werden, und überprüfe anschließend, dass util.inspect() und console.log() die angeforderte verschachtelte Ausgabe für Entsorgungsfehler erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.4k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
277

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus nodejs/node

Alle Issues in nodejs/node

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.