From 14e013dabbad90de9622eeb70cfc6b4e484349e3 Mon Sep 17 00:00:00 2001 From: Sean Wentzel Date: Fri, 5 Jan 2024 14:23:46 -0800 Subject: [PATCH 1/4] expose process.binding('util').getPromiseDetails --- lib/internal/bootstrap/realm.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/internal/bootstrap/realm.js b/lib/internal/bootstrap/realm.js index 81144c280a1f41..85c6bb2d5a8f9a 100644 --- a/lib/internal/bootstrap/realm.js +++ b/lib/internal/bootstrap/realm.js @@ -155,7 +155,16 @@ const experimentalModuleList = new SafeSet(); 'DEP0111'); } if (legacyWrapperList.has(module)) { - return requireBuiltin('internal/legacy/processbinding')[module](); + const legacy = requireBuiltin('internal/legacy/processbinding')[module](); + if (module === 'util') { + // We need getPromiseDetails and constants.kFulfilled from `internalBinding('util')` + return { + ...legacy, + ...internalBinding('util'), + }; + } else { + return legacy; + } } return internalBinding(module); } From 00d8d99f6126d5fff7bc27eb4b21acd4ba55bb58 Mon Sep 17 00:00:00 2001 From: Sean Wentzel Date: Fri, 5 Jan 2024 15:22:16 -0800 Subject: [PATCH 2/4] satisfy linter --- lib/internal/bootstrap/realm.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/bootstrap/realm.js b/lib/internal/bootstrap/realm.js index 85c6bb2d5a8f9a..03be24bb429cc4 100644 --- a/lib/internal/bootstrap/realm.js +++ b/lib/internal/bootstrap/realm.js @@ -162,9 +162,8 @@ const experimentalModuleList = new SafeSet(); ...legacy, ...internalBinding('util'), }; - } else { - return legacy; } + return legacy; } return internalBinding(module); } From 636aca9193c3dd119d17c52a6a5d5afdbad9ea69 Mon Sep 17 00:00:00 2001 From: Sean Wentzel Date: Mon, 8 Jan 2024 11:59:51 -0800 Subject: [PATCH 3/4] fix test --- test/parallel/test-process-binding-util.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-process-binding-util.js b/test/parallel/test-process-binding-util.js index d1e602de681cfa..a430ff0131114b 100644 --- a/test/parallel/test-process-binding-util.js +++ b/test/parallel/test-process-binding-util.js @@ -7,8 +7,19 @@ const utilBinding = process.binding('util'); assert.deepStrictEqual( Object.keys(utilBinding).sort(), [ + 'WeakReference', + 'arrayBufferViewHasBuffer', + 'constants', + 'getCallerLocation', + 'getConstructorName', + 'getExternalValue', + 'getOwnNonIndexProperties', + 'getPromiseDetails', + 'getProxyDetails', + 'guessHandleType', 'isAnyArrayBuffer', 'isArrayBuffer', + 'isArrayBufferDetached', 'isArrayBufferView', 'isAsyncFunction', 'isDataView', @@ -23,8 +34,15 @@ assert.deepStrictEqual( 'isSetIterator', 'isTypedArray', 'isUint8Array', + 'previewEntries', + 'privateSymbols', + 'shouldAbortOnUncaughtToggle', + 'sleep', + 'toUSVString' ]); for (const k of Object.keys(utilBinding)) { - assert.strictEqual(utilBinding[k], util.types[k]); + if (k in util.types) { + assert.strictEqual(utilBinding[k], util.types[k]); + } } From e2961a4b79778e8172d1ca2bf99357a99e264157 Mon Sep 17 00:00:00 2001 From: Sean Wentzel Date: Mon, 8 Jan 2024 13:59:17 -0800 Subject: [PATCH 4/4] lint --- test/parallel/test-process-binding-util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-process-binding-util.js b/test/parallel/test-process-binding-util.js index a430ff0131114b..b01fdcedcb3e6e 100644 --- a/test/parallel/test-process-binding-util.js +++ b/test/parallel/test-process-binding-util.js @@ -38,7 +38,7 @@ assert.deepStrictEqual( 'privateSymbols', 'shouldAbortOnUncaughtToggle', 'sleep', - 'toUSVString' + 'toUSVString', ]); for (const k of Object.keys(utilBinding)) {