diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 96b620d057c5ca..39d1de65f8e77a 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -359,7 +359,8 @@ 'contextify', 'tcp_wrap', 'tls_wrap', - 'async_wrap']); + 'async_wrap', + 'os']); process.binding = function binding(name) { return internalBindingWhitelist.has(name) ? internalBinding(name) : diff --git a/lib/os.js b/lib/os.js index 09a70d2f7b19e5..9e2c72af3ced95 100644 --- a/lib/os.js +++ b/lib/os.js @@ -24,6 +24,7 @@ const { pushValToArrayMax, safeGetenv } = process.binding('util'); const constants = process.binding('constants').os; const { deprecate } = require('internal/util'); +const { internalBinding } = require('internal/bootstrap/loaders'); const isWindows = process.platform === 'win32'; const { codes: { ERR_SYSTEM_ERROR } } = require('internal/errors'); @@ -44,7 +45,7 @@ const { getUptime, isBigEndian, setPriority: _setPriority -} = process.binding('os'); +} = internalBinding('os'); function getCheckedFunction(fn) { return function checkError(...args) { diff --git a/src/node_os.cc b/src/node_os.cc index d3e9460f473122..fb413eb22ae81b 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -470,4 +470,4 @@ void Initialize(Local target, } // namespace os } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(os, node::os::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(os, node::os::Initialize) diff --git a/test/parallel/test-os-checked-function.js b/test/parallel/test-os-checked-function.js index 04c2c3a1f82ea3..d080b7561a1580 100644 --- a/test/parallel/test-os-checked-function.js +++ b/test/parallel/test-os-checked-function.js @@ -1,7 +1,11 @@ +// Flags: --expose-internals 'use strict'; + +const { internalBinding } = require('internal/test/binding'); + // Monkey patch the os binding before requiring any other modules, including // common, which requires the os module. -process.binding('os').getHomeDirectory = function(ctx) { +internalBinding('os').getHomeDirectory = function(ctx) { ctx.syscall = 'foo'; ctx.code = 'bar'; ctx.message = 'baz'; diff --git a/test/parallel/test-process-binding-internalbinding-whitelist.js b/test/parallel/test-process-binding-internalbinding-whitelist.js index 63ce002887db8a..825907b8f71658 100644 --- a/test/parallel/test-process-binding-internalbinding-whitelist.js +++ b/test/parallel/test-process-binding-internalbinding-whitelist.js @@ -12,3 +12,4 @@ assert(process.binding('v8')); assert(process.binding('stream_wrap')); assert(process.binding('signal_wrap')); assert(process.binding('contextify')); +assert(process.binding('os'));