process: load internal/async_hooks before inspector hooks registration
Otherwise the exports of `internal/async_hooks` may be undefined when the inspector async hooks are registered. PR-URL: https://github.com/nodejs/node/pull/26866 Fixes: https://github.com/nodejs/node/issues/26798 Refs: https://github.com/nodejs/node/pull/26859 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
2b89ac6818
commit
0d21299384
@ -89,16 +89,6 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
|
||||
const emitPromiseResolveNative =
|
||||
emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative');
|
||||
|
||||
// Setup the callbacks that node::AsyncWrap will call when there are hooks to
|
||||
// process. They use the same functions as the JS embedder API. These callbacks
|
||||
// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
|
||||
// and the cost of doing so is negligible.
|
||||
async_wrap.setupHooks({ init: emitInitNative,
|
||||
before: emitBeforeNative,
|
||||
after: emitAfterNative,
|
||||
destroy: emitDestroyNative,
|
||||
promise_resolve: emitPromiseResolveNative });
|
||||
|
||||
// Used to fatally abort the process if a callback throws.
|
||||
function fatalError(e) {
|
||||
if (typeof e.stack === 'string') {
|
||||
@ -461,4 +451,11 @@ module.exports = {
|
||||
emitAfter: emitAfterScript,
|
||||
emitDestroy: emitDestroyScript,
|
||||
registerDestroyHook,
|
||||
nativeHooks: {
|
||||
init: emitInitNative,
|
||||
before: emitBeforeNative,
|
||||
after: emitAfterNative,
|
||||
destroy: emitDestroyNative,
|
||||
promise_resolve: emitPromiseResolveNative
|
||||
}
|
||||
};
|
||||
|
@ -150,6 +150,16 @@ if (isMainThread) {
|
||||
setupProcessStdio(getStdout, getStdin, getStderr);
|
||||
}
|
||||
|
||||
// Setup the callbacks that node::AsyncWrap will call when there are hooks to
|
||||
// process. They use the same functions as the JS embedder API. These callbacks
|
||||
// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
|
||||
// and the cost of doing so is negligible.
|
||||
const { nativeHooks } = require('internal/async_hooks');
|
||||
internalBinding('async_wrap').setupHooks(nativeHooks);
|
||||
|
||||
// XXX(joyeecheung): this has to be done after the initial load of
|
||||
// `internal/async_hooks` otherwise `async_hooks` cannot require
|
||||
// `internal/async_hooks`. Investigate why.
|
||||
if (config.hasInspector) {
|
||||
const {
|
||||
enable,
|
||||
|
Loading…
x
Reference in New Issue
Block a user