Skip to content

Commit 6f5ced6

Browse files
BridgeARMylesBorins
authored andcommitted
src: accept single argument in getProxyDetails
This makes sure this function stays backwards compatible in case it's accessed through the binding directly. Refs: #29947 (comment) Backport-PR-URL: #31431 PR-URL: #30858 Refs: #30767 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent cc19d08 commit 6f5ced6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/node_util.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
9191
if (!args[0]->IsProxy())
9292
return;
9393

94-
CHECK(args[1]->IsBoolean());
95-
9694
Local<Proxy> proxy = args[0].As<Proxy>();
9795

98-
if (args[1]->IsTrue()) {
96+
// TODO(BridgeAR): Remove the length check as soon as we prohibit access to
97+
// the util binding layer. It's accessed in the wild and `esm` would break in
98+
// case the check is removed.
99+
if (args.Length() == 1 || args[1]->IsTrue()) {
99100
Local<Value> ret[] = {
100101
proxy->GetTarget(),
101102
proxy->GetHandler()

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

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ let details = processUtil.getProxyDetails(proxyObj, true);
5050
assert.strictEqual(target, details[0]);
5151
assert.strictEqual(handler, details[1]);
5252

53+
details = processUtil.getProxyDetails(proxyObj);
54+
assert.strictEqual(target, details[0]);
55+
assert.strictEqual(handler, details[1]);
56+
5357
details = processUtil.getProxyDetails(proxyObj, false);
5458
assert.strictEqual(target, details);
5559

0 commit comments

Comments
 (0)