diff --git a/lib/internal/bootstrap/realm.js b/lib/internal/bootstrap/realm.js index 6034af9a36003c..93a939cc7e4645 100644 --- a/lib/internal/bootstrap/realm.js +++ b/lib/internal/bootstrap/realm.js @@ -87,34 +87,26 @@ ObjectDefineProperty(process, 'moduleLoadList', { // more, we just implement them as legacy wrappers instead. See the // legacyWrapperList. const processBindingAllowList = new SafeSet([ - 'async_wrap', 'buffer', 'cares_wrap', 'config', 'constants', 'contextify', - 'crypto', 'fs', 'fs_event_wrap', - 'http_parser', 'icu', 'inspector', 'js_stream', - 'natives', 'os', 'pipe_wrap', 'process_wrap', - 'signal_wrap', 'spawn_sync', 'stream_wrap', 'tcp_wrap', 'tls_wrap', 'tty_wrap', 'udp_wrap', - 'url', - 'util', 'uv', - 'v8', 'zlib', ]); @@ -148,19 +140,23 @@ const experimentalModuleList = new SafeSet(); process.binding = function binding(module) { module = String(module); + const mod = bindingObj[module]; + if (typeof mod === 'object') { + return mod; + } // Deprecated specific process.binding() modules, but not all, allow // selective fallback to internalBinding for the deprecated ones. + if (runtimeDeprecatedList.has(module)) { + process.emitWarning( + `Access to process.binding('${module}') is deprecated.`, + 'DeprecationWarning', + 'DEP0111'); + return internalBinding(module); + } + if (legacyWrapperList.has(module)) { + return requireBuiltin('internal/legacy/processbinding')[module](); + } if (processBindingAllowList.has(module)) { - if (runtimeDeprecatedList.has(module)) { - runtimeDeprecatedList.delete(module); - process.emitWarning( - `Access to process.binding('${module}') is deprecated.`, - 'DeprecationWarning', - 'DEP0111'); - } - if (legacyWrapperList.has(module)) { - return requireBuiltin('internal/legacy/processbinding')[module](); - } return internalBinding(module); } // eslint-disable-next-line no-restricted-syntax