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

async_hooks: remove async_wrap from async_hooks.js #19368

Closed
wants to merge 1 commit into from
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
5 changes: 2 additions & 3 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const {
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ASYNC_ID
} = require('internal/errors').codes;
const async_wrap = process.binding('async_wrap');
const internal_async_hooks = require('internal/async_hooks');

// Get functions
// For userland AsyncResources, make sure to emit a destroy event when the
// resource gets gced.
const { registerDestroyHook } = async_wrap;
const { registerDestroyHook } = internal_async_hooks;
const {
executionAsyncId,
triggerAsyncId,
Expand All @@ -38,7 +37,7 @@ const {
// Get constants
const {
kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve,
} = async_wrap.constants;
} = internal_async_hooks.constants;

// Listener API //

Expand Down
7 changes: 6 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ const active_hooks = {
tmp_fields: null
};

const { registerDestroyHook } = async_wrap;

// Each constant tracks how many callbacks there are for any given step of
// async execution. These are tracked so if the user didn't include callbacks
// for a given step, that step can bail out early.
const { kInit, kBefore, kAfter, kDestroy, kPromiseResolve,
const { kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve,
kCheck, kExecutionAsyncId, kAsyncIdCounter, kTriggerAsyncId,
kDefaultTriggerAsyncId, kStackLength } = async_wrap.constants;

Expand Down Expand Up @@ -435,6 +436,9 @@ module.exports = {
init_symbol, before_symbol, after_symbol, destroy_symbol,
promise_resolve_symbol
},
constants: {
kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve
},
enableHooks,
disableHooks,
clearDefaultTriggerAsyncId,
Expand All @@ -452,4 +456,5 @@ module.exports = {
emitBefore: emitBeforeScript,
emitAfter: emitAfterScript,
emitDestroy: emitDestroyScript,
registerDestroyHook,
};