From 578f0b0bf4fa39da86cc989a5caf822315ad649b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 8 Dec 2019 21:38:25 +0100 Subject: [PATCH 1/3] src: accept single argument in getProxyDetails This makes sure this function stays backwards compatible in case it's accessed through the binding directly. Refs: https://github.com/nodejs/node/pull/29947#issuecomment-562987888 --- src/node_util.cc | 5 ++--- test/parallel/test-util-inspect-proxy.js | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index b9553eaaa6763d..364502e558b468 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -91,11 +91,10 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { if (!args[0]->IsProxy()) return; - CHECK(args[1]->IsBoolean()); - Local proxy = args[0].As(); - if (args[1]->IsTrue()) { + // The length check keeps this function backwards compatible. + if (args.Length() == 1 || args[1]->IsTrue()) { Local ret[] = { proxy->GetTarget(), proxy->GetHandler() diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index 505503d5790759..3e1341fadfc9f9 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -50,6 +50,10 @@ let details = processUtil.getProxyDetails(proxyObj, true); assert.strictEqual(target, details[0]); assert.strictEqual(handler, details[1]); +details = processUtil.getProxyDetails(proxyObj); +assert.strictEqual(target, details[0]); +assert.strictEqual(handler, details[1]); + details = processUtil.getProxyDetails(proxyObj, false); assert.strictEqual(target, details); From e42bfc63d87d6bed9de3554e66070d6c9c959207 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 9 Dec 2019 11:49:35 +0100 Subject: [PATCH 2/3] fixup: change comment to TODO --- src/node_util.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_util.cc b/src/node_util.cc index 364502e558b468..1ee5258d150d18 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -93,7 +93,9 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { Local proxy = args[0].As(); - // The length check keeps this function backwards compatible. + // TODO(BridgeAR): Remove the length check as soon as we prohibit access to + // the util binding layer. It's accessed in the wild and some code would break + // in case the check is removed. if (args.Length() == 1 || args[1]->IsTrue()) { Local ret[] = { proxy->GetTarget(), From aa2f0bff6332d744c885f644f6adc54491bb6ae4 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 9 Dec 2019 12:05:38 +0100 Subject: [PATCH 3/3] fixup: mention esm explictly --- src/node_util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index 1ee5258d150d18..e0ef7d421ff24a 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -94,8 +94,8 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { Local proxy = args[0].As(); // TODO(BridgeAR): Remove the length check as soon as we prohibit access to - // the util binding layer. It's accessed in the wild and some code would break - // in case the check is removed. + // the util binding layer. It's accessed in the wild and `esm` would break in + // case the check is removed. if (args.Length() == 1 || args[1]->IsTrue()) { Local ret[] = { proxy->GetTarget(),