Skip to content

Commit 444e81f

Browse files
committed
fix: keep proxies opaque in util.inspect when showProxy is false
1 parent dc3236b commit 444e81f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/parallel/test-util-inspect-proxy.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,25 @@ const expected10 = '[Function (anonymous)]';
179179
const expected11 = '[Function (anonymous)]';
180180
assert.strictEqual(util.inspect(proxy10), expected10);
181181
assert.strictEqual(util.inspect(proxy11), expected11);
182+
183+
// Regression test for https://github.com/nodejs/node/issues/61061
184+
{
185+
const throwingProxy = new Proxy({}, {
186+
get() {
187+
throw new EvalError('boom');
188+
}
189+
});
190+
191+
const nestedThrowingProxy = new Proxy(throwingProxy, {});
192+
193+
// showProxy: false must NOT trigger proxy traps
194+
assert.doesNotThrow(() => {
195+
const result = util.inspect(throwingProxy, { showProxy: false });
196+
assert.strictEqual(result, '{}');
197+
});
198+
199+
assert.doesNotThrow(() => {
200+
const result = util.inspect(nestedThrowingProxy, { showProxy: false });
201+
assert.strictEqual(result, '{}');
202+
});
203+
}

0 commit comments

Comments
 (0)