lib: legitimize SuppressedError as primordial

Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/67551
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
Livia Medeiros authored and Antoine du Hamel committed 2026-11-23 12:34:21 +01:00
1 parent a5fd90f595
commit 4b810e2c5e
3 files changed
+4 -4

No files matched your search

+2 -1
View File
@@ -23,7 +23,7 @@ const noRestrictedSyntax = [
message: "`btoa` supports only latin-1 charset, use Buffer.from(str).toString('base64') instead",
},
{
selector: 'NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError|NodeAggregateError|QuicError|QuotaExceededError)$/])',
selector: 'NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError|NodeAggregateError|QuicError|QuotaExceededError|SuppressedError)$/])',
message: "Use an error exported by 'internal/errors' instead.",
},
{
@@ -507,6 +507,7 @@ export default [
into: 'Safe',
},
{ name: 'String' },
{ name: 'SuppressedError' },
{ name: 'Symbol' },
{ name: 'SyntaxError' },
{ name: 'TypeError' },
+1 -2
View File
@@ -19,6 +19,7 @@ const {
PromisePrototypeThen,
PromiseWithResolvers,
SafeSet,
SuppressedError,
Symbol,
SymbolAsyncDispose,
SymbolAsyncIterator,
@@ -1231,14 +1232,12 @@ function invokeOnerror(fn, error) {
if (isPromise(result)) {
PromisePrototypeThen(result, undefined, (err) => {
process.nextTick(() => {
// eslint-disable-next-line no-restricted-syntax
throw new SuppressedError(err, error, err?.message);
});
});
}
} catch (err) {
process.nextTick(() => {
// eslint-disable-next-line no-restricted-syntax
throw new SuppressedError(err, error, err?.message);
});
}
+1 -1
View File
@@ -22,6 +22,7 @@ const {
PromisePrototypeThen,
SafePromiseAllReturnVoid,
SafeSet,
SuppressedError,
Symbol,
SymbolAsyncIterator,
TypedArrayPrototypeGetBuffer,
@@ -645,7 +646,6 @@ async function cleanupIterators(iterators, primaryError, pendingPulls) {
// Both a primary error and a cleanup error occurred.
// Wrap in SuppressedError so neither is lost:
// .error = primaryError, .suppressed = cleanupError.
// eslint-disable-next-line no-restricted-syntax
throw new SuppressedError(primaryError, cleanupError);
}
// No primary error - the cleanup error is the only error.