Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: move process.binding('async_wrap') internal #22469

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const {
ERR_ASYNC_TYPE,
ERR_INVALID_ASYNC_ID
} = require('internal/errors').codes;
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const async_wrap = internalBinding('async_wrap');
/* async_hook_fields is a Uint32Array wrapping the uint32_t array of
* Environment::AsyncHooks::fields_[]. Each index tracks the number of active
* hooks for each type.
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@
'crypto',
'contextify',
'tcp_wrap',
'tls_wrap']);
'tls_wrap',
'async_wrap']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/pbkdf2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { INT_MAX, pbkdf2: _pbkdf2 } = internalBinding('crypto');
const { validateInt32 } = require('internal/validators');
const {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer, kMaxLength } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer, kMaxLength } = require('buffer');
const { randomBytes: _randomBytes } = internalBinding('crypto');
const {
ERR_INVALID_ARG_TYPE,
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { INT_MAX, scrypt: _scrypt } = internalBinding('crypto');
const { validateInt32 } = require('internal/validators');
const {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { internalBinding } = require('internal/bootstrap/loaders');
const { trace } = internalBinding('trace_events');
const async_wrap = process.binding('async_wrap');
const async_wrap = internalBinding('async_wrap');
const async_hooks = require('async_hooks');
const { SafeMap, SafeSet } = require('internal/safe_globals');

Expand Down
2 changes: 1 addition & 1 deletion src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,4 @@ Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) {

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(async_wrap, node::AsyncWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(async_wrap, node::AsyncWrap::Initialize)
3 changes: 2 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
const destroydIdsList = {};
const destroyListList = {};
const initHandles = {};
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');

process.on('exit', () => {
// iterate through handles to make sure nothing crashes
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-async-wrap-destroyid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');
const assert = require('assert');
const async_hooks = require('async_hooks');
const RUNS = 5;
Expand Down
4 changes: 3 additions & 1 deletion test/pseudo-tty/test-async-wrap-getasyncid-tty.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Flags: --expose-internals --no-warnings
'use strict';

// see also test/sequential/test-async-wrap-getasyncid.js

const common = require('../common');
const assert = require('assert');
const tty_wrap = process.binding('tty_wrap');
const { TTYWRAP } = process.binding('async_wrap').Providers;
const { internalBinding } = require('internal/test/binding');
const { TTYWRAP } = internalBinding('async_wrap').Providers;
const providers = { TTYWRAP };

// Make sure that the TTYWRAP Provider is tested.
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const assert = require('assert');
const fs = require('fs');
const fsPromises = fs.promises;
const net = require('net');
const providers = Object.assign({}, process.binding('async_wrap').Providers);
const providers = Object.assign({}, internalBinding('async_wrap').Providers);
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { getSystemErrorName } = require('util');
Expand Down
4 changes: 3 additions & 1 deletion test/sequential/test-inspector-async-call-stack.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();

const assert = require('assert');
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');
const { kTotals } = async_wrap.constants;
const inspector = require('inspector');

Expand Down