-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Description
Version
v20.19.5, v22.19.0, v24.8.0
Platform
Darwin MacBook-Pro-M1.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64
Subsystem
Util
What steps will reproduce the bug?
const error = {
// The error message itself is a getter that throws
get message() { throw new Error('Oops'); }
};
const thrower = {
get foo() { throw error; }
};
util.inspect(thrower, { getters: true });How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
Simply return the object getter as "<Inspection threw>" without the message that threw.
What do you see instead?
$ node -e 'util.inspect({get foo() { throw{ get message() { throw new Error }} }}, { getters: true })'
node:internal/util/inspect:1435
if (!isStackOverflowError(err)) throw err;
^
Error
at get message ([eval]:1:56)
at formatProperty (node:internal/util/inspect:2560:51)
at formatRaw (node:internal/util/inspect:1428:9)
at formatValue (node:internal/util/inspect:1183:10)
at Object.inspect (node:internal/util/inspect:409:10)
at [eval]:1:6
at runScriptInThisContext (node:internal/vm:219:10)
at node:internal/process/execution:451:12
at [eval]-wrapper:6:24
at runScriptInContext (node:internal/process/execution:449:60)
Node.js v26.0.0-preAdditional information
Related to another issue 3 weeks ago:
- Defend against crashing getters in util.inspect: fix error when logging DOMException.prototype (#60107) #60210
- util: use more defensive code when inspecting error objects #60139
This issue also highlights robustness concerns described in OWASP 2025 (A10 – Mishandling of Exceptional Conditions):
Catching and handling exceptional conditions ensures that the underlying infrastructure of our programs are not left to deal with unpredictable situations.
Note that I did not encounter this problem in real-world objects; I discovered it by reading the Node.js source code while investigating behavior.
Metadata
Metadata
Assignees
Labels
No labels