From 161dbe50ca5cf6ae170c72166af706121dc3b5d7 Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Sun, 15 May 2022 17:29:53 +0900 Subject: [PATCH] fixup: fix util.format on a revoked proxy Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com --- lib/internal/util/inspect.js | 2 +- test/parallel/test-util-inspect-proxy.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 97ba51959d81cc..0b1a776c9cd1bb 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1979,7 +1979,7 @@ function hasBuiltInToString(value) { } // Count objects that have no `toString` function as built-in. - if (typeof value.toString !== 'function') { + if (typeof value?.toString !== 'function') { return true; } diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index 45b8449aac2fac..30365f43f7b9a6 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -76,6 +76,8 @@ assert.strictEqual( '{ proxy: Proxy [ null, null ], revoke: [Function (anonymous)] }', ); +assert.strictEqual(util.format('%s', r.proxy), 'Proxy []'); + assert.strictEqual( util.inspect(proxyObj, opts), 'Proxy [\n' +