util: fix inspecting error with a throwing getter for cause

PR-URL: https://github.com/nodejs/node/pull/47163
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Antoine du Hamel
2023-03-31 18:27:52 +02:00
committed by GitHub
parent 841f6b3abf
commit 863ac8fa37
3 changed files with 25 additions and 2 deletions

View File

@@ -46,3 +46,9 @@ process.nextTick(() => {
console.log(inspect(cause3));
console.log(inspect(error2));
});
{
const error = new Error('cause that throws');
Reflect.defineProperty(error, 'cause', { get() { throw new Error(); } });
console.log(inspect(error));
}

View File

@@ -33,6 +33,16 @@ Error: undefined cause
at * {
[cause]: undefined
}
Error: cause that throws
at *
at *
at *
at *
at *
at *
at * {
[cause]: [Getter]
}
RangeError: New Stack Frames
at *
*[90m at *[39m {