diff --git a/doc/api/cli.md b/doc/api/cli.md index 7bfe03b77b6d..e3c5d400695d 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -139,6 +139,46 @@ Error: Cannot load native addon because loading addons is disabled. } ``` +### `--allow-async-hooks` + + + +Allow use of `async_hooks.createHook()`. This flag is required to enable +the `createHook` API, which is disabled by default. + +Example: + +```mjs +import { createHook } from 'node:async_hooks'; + +createHook({ init() {} }).enable(); +``` + +```cjs +const { createHook } = require('node:async_hooks'); + +createHook({ init() {} }).enable(); +``` + +```console +$ node index.js +node:async_hooks:160 + throw new ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED(); + ^ + +Error [ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED]: async_hooks.createHook() is disabled. Use --allow-async-hooks to enable it. + at createHook (node:async_hooks:160:11) + at Object. (/home/user/index.js:3:1) + ... +``` + +```console +$ node --allow-async-hooks index.js +# Works without error +``` + ### `--allow-child-process` * `--allow-addons` +* `--allow-async-hooks` * `--allow-child-process` * `--allow-env` * `--allow-ffi` diff --git a/doc/api/errors.md b/doc/api/errors.md index 1d812bd0b332..dc28d345f9b4 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -733,6 +733,17 @@ by the `node:assert` module. An attempt was made to register something that is not a function as an `AsyncHooks` callback. + + +### `ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED` + + + +An attempt was made to call [`async_hooks.createHook()`][] without the +[`--allow-async-hooks`][] flag. + ### `ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED` @@ -4770,6 +4781,7 @@ An error occurred trying to allocate memory. This should never happen. [`"exports"`]: packages.md#exports [`"imports"`]: packages.md#imports [`'uncaughtException'`]: process.md#event-uncaughtexception +[`--allow-async-hooks`]: cli.md#--allow-async-hooks [`--disable-proto=throw`]: cli.md#--disable-protomode [`--force-fips`]: cli.md#--force-fips [`--no-addons`]: cli.md#--no-addons @@ -4795,6 +4807,7 @@ An error occurred trying to allocate memory. This should never happen. [`Writable`]: stream.md#class-streamwritable [`ZipBuffer`]: zlib.md#class-zlibzipbuffer [`ZipFile`]: zlib.md#class-zlibzipfile +[`async_hooks.createHook()`]: async_hooks.md#async_hookscreatehookoptions [`child_process`]: child_process.md [`cipher.getAuthTag()`]: crypto.md#ciphergetauthtag [`crypto.getDiffieHellman()`]: crypto.md#cryptogetdiffiehellmangroupname diff --git a/doc/node.1 b/doc/node.1 index c79f46cd2cea..d17a0a00c62d 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -86,6 +86,36 @@ Error: Cannot load native addon because loading addons is disabled. } .Ed . +.It Fl -allow-async-hooks +Allow use of \fBasync_hooks.createHook()\fR. This flag is required to enable +the \fBcreateHook\fR API, which is disabled by default. +Example: +.Bd -literal +import { createHook } from 'node:async_hooks'; + +createHook({ init() {} }).enable(); +.Ed +.Bd -literal +const { createHook } = require('node:async_hooks'); + +createHook({ init() {} }).enable(); +.Ed +.Bd -literal +$ node index.js +node:async_hooks:160 + throw new ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED(); + ^ + +Error [ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED]: async_hooks.createHook() is disabled. Use --allow-async-hooks to enable it. + at createHook (node:async_hooks:160:11) + at Object. (/home/user/index.js:3:1) + ... +.Ed +.Bd -literal +$ node --allow-async-hooks index.js +# Works without error +.Ed +. .It Fl -allow-child-process When using the Permission Model, the process will not be able to spawn any child process by default. @@ -2167,6 +2197,8 @@ one is included in the list below. .It \fB--allow-addons\fR .It +\fB--allow-async-hooks\fR +.It \fB--allow-child-process\fR .It \fB--allow-env\fR diff --git a/lib/async_hooks.js b/lib/async_hooks.js index b0106020d64c..cba7ecde3d4a 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -1,10 +1,6 @@ 'use strict'; const { - ArrayPrototypeIncludes, - ArrayPrototypeIndexOf, - ArrayPrototypePush, - ArrayPrototypeSplice, ArrayPrototypeUnshift, FunctionPrototypeBind, NumberIsSafeInteger, @@ -15,20 +11,19 @@ const { } = primordials; const { - ERR_ASYNC_CALLBACK, + ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED, ERR_ASYNC_RESOURCE_DOMAIN_REMOVED, ERR_ASYNC_TYPE, ERR_INVALID_ASYNC_ID, - ERR_INVALID_ARG_VALUE, } = require('internal/errors').codes; const { kEmptyObject, } = require('internal/util'); const { - validateBoolean, validateFunction, validateString, } = require('internal/validators'); +const { getOptionValue } = require('internal/options'); const internal_async_hooks = require('internal/async_hooks'); const AsyncContextFrame = require('internal/async_context_frame'); @@ -36,17 +31,13 @@ const AsyncContextFrame = require('internal/async_context_frame'); // Get functions // For userland AsyncResources, make sure to emit a destroy event when the // resource gets gced. -const { registerDestroyHook, kNoPromiseHook } = internal_async_hooks; +const { registerDestroyHook } = internal_async_hooks; const { asyncWrap, executionAsyncId, triggerAsyncId, // Private API hasAsyncIdStack, - getHookArrays, - enableHooks, - disableHooks, - updatePromiseHookMode, executionAsyncResource, // Internal Embedder API newAsyncId, @@ -57,118 +48,21 @@ const { emitDestroy, initHooksExist, destroyHooksExist, + createHook: createHookInternal, } = internal_async_hooks; // Get symbols const { async_id_symbol, trigger_async_id_symbol, - init_symbol, before_symbol, after_symbol, destroy_symbol, - promise_resolve_symbol, } = internal_async_hooks.symbols; -// Get constants -const { - kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve, -} = internal_async_hooks.constants; - // Listener API // -class AsyncHook { - constructor({ init, before, after, destroy, promiseResolve, trackPromises }) { - if (init !== undefined && typeof init !== 'function') - throw new ERR_ASYNC_CALLBACK('hook.init'); - if (before !== undefined && typeof before !== 'function') - throw new ERR_ASYNC_CALLBACK('hook.before'); - if (after !== undefined && typeof after !== 'function') - throw new ERR_ASYNC_CALLBACK('hook.after'); - if (destroy !== undefined && typeof destroy !== 'function') - throw new ERR_ASYNC_CALLBACK('hook.destroy'); - if (promiseResolve !== undefined && typeof promiseResolve !== 'function') - throw new ERR_ASYNC_CALLBACK('hook.promiseResolve'); - if (trackPromises !== undefined) { - validateBoolean(trackPromises, 'trackPromises'); - } - - this[init_symbol] = init; - this[before_symbol] = before; - this[after_symbol] = after; - this[destroy_symbol] = destroy; - this[promise_resolve_symbol] = promiseResolve; - if (trackPromises === false) { - if (promiseResolve) { - throw new ERR_INVALID_ARG_VALUE('trackPromises', - trackPromises, 'must not be false when promiseResolve is enabled'); - } - this[kNoPromiseHook] = true; - } else { - // Default to tracking promises for now. - this[kNoPromiseHook] = false; - } - } - - enable() { - // The set of callbacks for a hook should be the same regardless of whether - // enable()/disable() are run during their execution. The following - // references are reassigned to the tmp arrays if a hook is currently being - // processed. - const { 0: hooks_array, 1: hook_fields } = getHookArrays(); - - // Each hook is only allowed to be added once. - if (ArrayPrototypeIncludes(hooks_array, this)) - return this; - - const prev_kTotals = hook_fields[kTotals]; - - // createHook() has already enforced that the callbacks are all functions, - // so here simply increment the count of whether each callbacks exists or - // not. - hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol]; - hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol]; - hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol]; - hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol]; - hook_fields[kTotals] += - hook_fields[kPromiseResolve] += +!!this[promise_resolve_symbol]; - ArrayPrototypePush(hooks_array, this); - - if (prev_kTotals === 0 && hook_fields[kTotals] > 0) { - enableHooks(); - } - - if (!this[kNoPromiseHook]) { - updatePromiseHookMode(); - } - - return this; - } - - disable() { - const { 0: hooks_array, 1: hook_fields } = getHookArrays(); - - const index = ArrayPrototypeIndexOf(hooks_array, this); - if (index === -1) - return this; - - const prev_kTotals = hook_fields[kTotals]; - - hook_fields[kTotals] = hook_fields[kInit] -= +!!this[init_symbol]; - hook_fields[kTotals] += hook_fields[kBefore] -= +!!this[before_symbol]; - hook_fields[kTotals] += hook_fields[kAfter] -= +!!this[after_symbol]; - hook_fields[kTotals] += hook_fields[kDestroy] -= +!!this[destroy_symbol]; - hook_fields[kTotals] += - hook_fields[kPromiseResolve] -= +!!this[promise_resolve_symbol]; - ArrayPrototypeSplice(hooks_array, index, 1); - - if (prev_kTotals > 0 && hook_fields[kTotals] === 0) { - disableHooks(); - } - - return this; - } -} - - function createHook(fns) { - return new AsyncHook(fns); + if (!getOptionValue('--allow-async-hooks')) { + throw new ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED(); + } + return createHookInternal(fns); } diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 8a60b9a6ce52..7f7671e8c336 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -1,7 +1,11 @@ 'use strict'; const { + ArrayPrototypeIncludes, + ArrayPrototypeIndexOf, + ArrayPrototypePush, ArrayPrototypeSlice, + ArrayPrototypeSplice, ErrorCaptureStackTrace, ObjectDefineProperty, ObjectPrototypeHasOwnProperty, @@ -10,6 +14,11 @@ const { } = primordials; const { exitCodes: { kGenericUserError } } = internalBinding('errors'); +const { + ERR_ASYNC_CALLBACK, + ERR_INVALID_ARG_VALUE, +} = require('internal/errors').codes; +const { validateBoolean } = require('internal/validators'); const async_wrap = internalBinding('async_wrap'); const { setCallbackTrampoline } = async_wrap; @@ -576,6 +585,105 @@ function triggerAsyncId() { const kNoPromiseHook = Symbol('kNoPromiseHook'); +class AsyncHook { + constructor({ init, before, after, destroy, promiseResolve, trackPromises }) { + if (init !== undefined && typeof init !== 'function') + throw new ERR_ASYNC_CALLBACK('hook.init'); + if (before !== undefined && typeof before !== 'function') + throw new ERR_ASYNC_CALLBACK('hook.before'); + if (after !== undefined && typeof after !== 'function') + throw new ERR_ASYNC_CALLBACK('hook.after'); + if (destroy !== undefined && typeof destroy !== 'function') + throw new ERR_ASYNC_CALLBACK('hook.destroy'); + if (promiseResolve !== undefined && typeof promiseResolve !== 'function') + throw new ERR_ASYNC_CALLBACK('hook.promiseResolve'); + if (trackPromises !== undefined) { + validateBoolean(trackPromises, 'trackPromises'); + } + + this[init_symbol] = init; + this[before_symbol] = before; + this[after_symbol] = after; + this[destroy_symbol] = destroy; + this[promise_resolve_symbol] = promiseResolve; + if (trackPromises === false) { + if (promiseResolve) { + throw new ERR_INVALID_ARG_VALUE('trackPromises', + trackPromises, 'must not be false when promiseResolve is enabled'); + } + this[kNoPromiseHook] = true; + } else { + // Default to tracking promises for now. + this[kNoPromiseHook] = false; + } + } + + enable() { + // The set of callbacks for a hook should be the same regardless of whether + // enable()/disable() are run during their execution. The following + // references are reassigned to the tmp arrays if a hook is currently being + // processed. + const { 0: hooks_array, 1: hook_fields } = getHookArrays(); + + // Each hook is only allowed to be added once. + if (ArrayPrototypeIncludes(hooks_array, this)) + return this; + + const prev_kTotals = hook_fields[kTotals]; + + // createHook() has already enforced that the callbacks are all functions, + // so here simply increment the count of whether each callbacks exists or + // not. + hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol]; + hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol]; + hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol]; + hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol]; + hook_fields[kTotals] += + hook_fields[kPromiseResolve] += +!!this[promise_resolve_symbol]; + ArrayPrototypePush(hooks_array, this); + + if (prev_kTotals === 0 && hook_fields[kTotals] > 0) { + enableHooks(); + } + + if (!this[kNoPromiseHook]) { + updatePromiseHookMode(); + } + + return this; + } + + disable() { + const { 0: hooks_array, 1: hook_fields } = getHookArrays(); + + const index = ArrayPrototypeIndexOf(hooks_array, this); + if (index === -1) + return this; + + const prev_kTotals = hook_fields[kTotals]; + + hook_fields[kTotals] = hook_fields[kInit] -= +!!this[init_symbol]; + hook_fields[kTotals] += hook_fields[kBefore] -= +!!this[before_symbol]; + hook_fields[kTotals] += hook_fields[kAfter] -= +!!this[after_symbol]; + hook_fields[kTotals] += hook_fields[kDestroy] -= +!!this[destroy_symbol]; + hook_fields[kTotals] += + hook_fields[kPromiseResolve] -= +!!this[promise_resolve_symbol]; + ArrayPrototypeSplice(hooks_array, index, 1); + + if (prev_kTotals > 0 && hook_fields[kTotals] === 0) { + disableHooks(); + } + + return this; + } +} + +// Creates an AsyncHook without checking --allow-async-hooks. Only for use by +// Node.js internals; userland goes through async_hooks.createHook(). +function createHook(fns) { + return new AsyncHook(fns); +} + module.exports = { executionAsyncId, triggerAsyncId, @@ -624,4 +732,5 @@ module.exports = { Providers: async_wrap.Providers, }, kNoPromiseHook, + createHook, }; diff --git a/lib/internal/errors.js b/lib/internal/errors.js index ddd07a98209d..a26926502356 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1143,6 +1143,8 @@ E('ERR_AMBIGUOUS_ARGUMENT', 'The "%s" argument is ambiguous. %s', TypeError); E('ERR_ARG_NOT_ITERABLE', '%s must be iterable', TypeError); E('ERR_ASSERTION', '%s', Error); E('ERR_ASYNC_CALLBACK', '%s must be a function', TypeError); +E('ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED', + 'async_hooks.createHook() is disabled. Use --allow-async-hooks to enable it.', Error); E('ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED', 'Async loader request never settled', Error); E('ERR_ASYNC_RESOURCE_DOMAIN_REMOVED', diff --git a/lib/internal/inspector_async_hook.js b/lib/internal/inspector_async_hook.js index 8ab833ea8ef1..4bafef870b78 100644 --- a/lib/internal/inspector_async_hook.js +++ b/lib/internal/inspector_async_hook.js @@ -5,7 +5,7 @@ let config; function lazyHookCreation() { const inspector = internalBinding('inspector'); - const { createHook } = require('async_hooks'); + const { createHook } = require('internal/async_hooks'); config = internalBinding('config'); hook = createHook({ diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 16f9392bf776..c2441acac0c2 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -13,7 +13,7 @@ const { getCallerLocation } = internalBinding('util'); const { createHook, executionAsyncId, -} = require('async_hooks'); +} = require('internal/async_hooks'); const { relative } = require('path'); const { codes: { diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 86de9e796474..eeddc1d5cabb 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -16,7 +16,7 @@ const { kSyncEnd, } = require('internal/trace_events'); const async_wrap = internalBinding('async_wrap'); -const async_hooks = require('async_hooks'); +const async_hooks = require('internal/async_hooks'); const kTraceEventCategory = nodeTraceEventCategory('node.async_hooks'); diff --git a/src/node_options.cc b/src/node_options.cc index 6bf5a0270c78..0ed8914aa90d 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -947,6 +947,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { kAllowedInEnvvar, false, OptionNamespaces::kPermissionNamespace); + AddOption("--allow-async-hooks", + "allow use of async_hooks.createHook", + BOOL_FIELD(allow_async_hooks), + kAllowedInEnvvar); AddOption("--allow-openssl-store", "allow use of OpenSSL STORE loaders when any permissions are set", BOOL_FIELD(allow_openssl_store), diff --git a/src/node_options.h b/src/node_options.h index bb11922f84fb..bd793d7b457d 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -238,6 +238,7 @@ class EnvironmentOptions : public Options { DEFINE_BOOL_FIELD(allow_ffi) = false; DEFINE_BOOL_FIELD(allow_openssl_store) = false; DEFINE_BOOL_FIELD(allow_worker_threads) = false; + DEFINE_BOOL_FIELD(allow_async_hooks) = false; DEFINE_BOOL_FIELD(experimental_vm_modules) = EXPERIMENTALS_DEFAULT_VALUE; DEFINE_BOOL_FIELD(expose_internals) = false; DEFINE_BOOL_FIELD(force_node_api_uncaught_exceptions_policy) = false; diff --git a/test/addons/async-resource/test.js b/test/addons/async-resource/test.js index d7bc44a92be8..397f75004f10 100644 --- a/test/addons/async-resource/test.js +++ b/test/addons/async-resource/test.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../../common'); const assert = require('assert'); diff --git a/test/addons/callback-scope/test-async-hooks.js b/test/addons/callback-scope/test-async-hooks.js index 2d1c8719b345..5c2183fa0925 100644 --- a/test/addons/callback-scope/test-async-hooks.js +++ b/test/addons/callback-scope/test-async-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../../common'); const assert = require('assert'); diff --git a/test/async-hooks/init-hooks.js b/test/async-hooks/init-hooks.js index 8fc44994fbc4..8faf3c35fdd3 100644 --- a/test/async-hooks/init-hooks.js +++ b/test/async-hooks/init-hooks.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-async-await.js b/test/async-hooks/test-async-await.js index 4fd698c8e981..3cd496b6f5cf 100644 --- a/test/async-hooks/test-async-await.js +++ b/test/async-hooks/test-async-await.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); // This test ensures async hooks are being properly called diff --git a/test/async-hooks/test-async-exec-resource-http-32060.js b/test/async-hooks/test-async-exec-resource-http-32060.js index 35869708dfc1..553a8eaa538b 100644 --- a/test/async-hooks/test-async-exec-resource-http-32060.js +++ b/test/async-hooks/test-async-exec-resource-http-32060.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const { diff --git a/test/async-hooks/test-async-exec-resource-http-agent.js b/test/async-hooks/test-async-exec-resource-http-agent.js index abc2df3a1930..92a2d6bc36a4 100644 --- a/test/async-hooks/test-async-exec-resource-http-agent.js +++ b/test/async-hooks/test-async-exec-resource-http-agent.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); diff --git a/test/async-hooks/test-async-exec-resource-http.js b/test/async-hooks/test-async-exec-resource-http.js index 0615a404045a..95d22142739c 100644 --- a/test/async-hooks/test-async-exec-resource-http.js +++ b/test/async-hooks/test-async-exec-resource-http.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-async-exec-resource-match.js b/test/async-hooks/test-async-exec-resource-match.js index 0b68b30ffa93..570763f78a42 100644 --- a/test/async-hooks/test-async-exec-resource-match.js +++ b/test/async-hooks/test-async-exec-resource-match.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-async-local-storage-gcable.js b/test/async-hooks/test-async-local-storage-gcable.js index 303442e60c88..8b8614139077 100644 --- a/test/async-hooks/test-async-local-storage-gcable.js +++ b/test/async-hooks/test-async-local-storage-gcable.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose_gc +// Flags: --allow-async-hooks --expose_gc // This test ensures that AsyncLocalStorage gets gced once it was disabled // and no strong references remain in userland. diff --git a/test/async-hooks/test-callback-error.js b/test/async-hooks/test-callback-error.js index ad70feb70c95..c690f31da31b 100644 --- a/test/async-hooks/test-callback-error.js +++ b/test/async-hooks/test-callback-error.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const { spawnSync } = require('child_process'); @@ -37,7 +38,7 @@ assert.ok(!arg); // console.log should stay until this test's flakiness is solved console.log('start case 1'); console.time('end case 1'); - const child = spawnSync(process.execPath, [__filename, 'test_init_callback']); + const child = spawnSync(process.execPath, ['--allow-async-hooks', __filename, 'test_init_callback']); assert.ifError(child.error); const test_init_first_line = child.stderr.toString().split(/[\r\n]+/g)[0]; assert.strictEqual(test_init_first_line, 'Error: test_init_callback'); @@ -48,7 +49,7 @@ assert.ok(!arg); { console.log('start case 2'); console.time('end case 2'); - const child = spawnSync(process.execPath, [__filename, 'test_callback']); + const child = spawnSync(process.execPath, ['--allow-async-hooks', __filename, 'test_callback']); assert.ifError(child.error); const test_callback_first_line = child.stderr.toString().split(/[\r\n]+/g)[0]; assert.strictEqual(test_callback_first_line, 'Error: test_callback'); @@ -61,10 +62,10 @@ assert.ok(!arg); console.time('end case 3'); let program = process.execPath; let args = [ - '--abort-on-uncaught-exception', __filename, 'test_callback_abort' ]; + '--allow-async-hooks', '--abort-on-uncaught-exception', __filename, 'test_callback_abort' ]; let options = {}; if (!common.isWindows) { - [program, options] = common.escapePOSIXShell`ulimit -c 0 && exec "${program}" ${args[0]} "${args[1]}" ${args[2]}`; + [program, options] = common.escapePOSIXShell`ulimit -c 0 && exec "${program}" ${args[0]} ${args[1]} "${args[2]}" ${args[3]}`; args = []; options.shell = true; } diff --git a/test/async-hooks/test-crypto-pbkdf2.js b/test/async-hooks/test-crypto-pbkdf2.js index c607adf72587..0adf4afc534c 100644 --- a/test/async-hooks/test-crypto-pbkdf2.js +++ b/test/async-hooks/test-crypto-pbkdf2.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) { diff --git a/test/async-hooks/test-crypto-randomBytes.js b/test/async-hooks/test-crypto-randomBytes.js index 8ecc1c45a9a5..e37daa6196d3 100644 --- a/test/async-hooks/test-crypto-randomBytes.js +++ b/test/async-hooks/test-crypto-randomBytes.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) { diff --git a/test/async-hooks/test-destroy-not-blocked.js b/test/async-hooks/test-destroy-not-blocked.js index 2bbddf3047bb..b2d4c0b549e1 100644 --- a/test/async-hooks/test-destroy-not-blocked.js +++ b/test/async-hooks/test-destroy-not-blocked.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose_gc +// Flags: --allow-async-hooks --expose_gc const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-disable-in-init.js b/test/async-hooks/test-disable-in-init.js index f810dfca3b96..adfdf5b98fdb 100644 --- a/test/async-hooks/test-disable-in-init.js +++ b/test/async-hooks/test-disable-in-init.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); diff --git a/test/async-hooks/test-embedder.api.async-resource-no-type.js b/test/async-hooks/test-embedder.api.async-resource-no-type.js index e21c5458df86..9fef866559f8 100644 --- a/test/async-hooks/test-embedder.api.async-resource-no-type.js +++ b/test/async-hooks/test-embedder.api.async-resource-no-type.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); @@ -25,7 +26,7 @@ if (process.argv[2] === 'child') { }); } else { - const args = process.argv.slice(1).concat('child'); + const args = ['--allow-async-hooks', ...process.argv.slice(1), 'child']; spawn(process.execPath, args) .on('close', common.mustCall((code) => { // No error because the type was defaulted diff --git a/test/async-hooks/test-embedder.api.async-resource.js b/test/async-hooks/test-embedder.api.async-resource.js index d60c03fb87b2..bdcfc1bb1c91 100644 --- a/test/async-hooks/test-embedder.api.async-resource.js +++ b/test/async-hooks/test-embedder.api.async-resource.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-emit-after-on-destroyed.js b/test/async-hooks/test-emit-after-on-destroyed.js index 719d6ab91a54..157379b049d6 100644 --- a/test/async-hooks/test-emit-after-on-destroyed.js +++ b/test/async-hooks/test-emit-after-on-destroyed.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); @@ -42,7 +42,7 @@ if (process.argv[2] === 'child') { emitAfter(asyncId); } } else { - const args = ['--expose-internals'] + const args = ['--allow-async-hooks', '--expose-internals'] .concat(process.argv.slice(1)) .concat('child'); let errData = Buffer.from(''); diff --git a/test/async-hooks/test-emit-before-after.js b/test/async-hooks/test-emit-before-after.js index 561004cac2f0..bc79586533e3 100644 --- a/test/async-hooks/test-emit-before-after.js +++ b/test/async-hooks/test-emit-before-after.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-emit-before-on-destroyed.js b/test/async-hooks/test-emit-before-on-destroyed.js index ca0553e53348..59b01ed678c9 100644 --- a/test/async-hooks/test-emit-before-on-destroyed.js +++ b/test/async-hooks/test-emit-before-on-destroyed.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); @@ -42,7 +42,7 @@ if (process.argv[2] === 'child') { emitBefore(asyncId, triggerId); } } else { - const args = ['--expose-internals'] + const args = ['--allow-async-hooks', '--expose-internals'] .concat(process.argv.slice(1)) .concat('child'); let errData = Buffer.from(''); diff --git a/test/async-hooks/test-emit-init.js b/test/async-hooks/test-emit-init.js index 8994943b4729..c190c51df3ba 100644 --- a/test/async-hooks/test-emit-init.js +++ b/test/async-hooks/test-emit-init.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-enable-disable.js b/test/async-hooks/test-enable-disable.js index d408338e892c..f891268d5269 100644 --- a/test/async-hooks/test-enable-disable.js +++ b/test/async-hooks/test-enable-disable.js @@ -81,6 +81,7 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-enable-in-init.js b/test/async-hooks/test-enable-in-init.js index e710657a3404..2e88cfa93e64 100644 --- a/test/async-hooks/test-enable-in-init.js +++ b/test/async-hooks/test-enable-in-init.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); diff --git a/test/async-hooks/test-filehandle-no-reuse.js b/test/async-hooks/test-filehandle-no-reuse.js index f607a7a22e08..5ac3ab51c9b6 100644 --- a/test/async-hooks/test-filehandle-no-reuse.js +++ b/test/async-hooks/test-filehandle-no-reuse.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-fseventwrap.js b/test/async-hooks/test-fseventwrap.js index a5e1a3b9d2f2..f7bf4d0feb69 100644 --- a/test/async-hooks/test-fseventwrap.js +++ b/test/async-hooks/test-fseventwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-fsreqcallback-access.js b/test/async-hooks/test-fsreqcallback-access.js index b1b75f569305..fe9bddba85de 100644 --- a/test/async-hooks/test-fsreqcallback-access.js +++ b/test/async-hooks/test-fsreqcallback-access.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-fsreqcallback-readFile.js b/test/async-hooks/test-fsreqcallback-readFile.js index fb84306cfa86..4d6fd112909f 100644 --- a/test/async-hooks/test-fsreqcallback-readFile.js +++ b/test/async-hooks/test-fsreqcallback-readFile.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-getaddrinforeqwrap.js b/test/async-hooks/test-getaddrinforeqwrap.js index a21557bcd56e..eaf7dcd9fccb 100644 --- a/test/async-hooks/test-getaddrinforeqwrap.js +++ b/test/async-hooks/test-getaddrinforeqwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-getnameinforeqwrap.js b/test/async-hooks/test-getnameinforeqwrap.js index b00fa0d4d9dd..a234beb83519 100644 --- a/test/async-hooks/test-getnameinforeqwrap.js +++ b/test/async-hooks/test-getnameinforeqwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-graph.fsreq-readFile.js b/test/async-hooks/test-graph.fsreq-readFile.js index 39435cdc4891..158e74ca0c7c 100644 --- a/test/async-hooks/test-graph.fsreq-readFile.js +++ b/test/async-hooks/test-graph.fsreq-readFile.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-graph.http.js b/test/async-hooks/test-graph.http.js index 859000b14aa8..f54deeba1a0e 100644 --- a/test/async-hooks/test-graph.http.js +++ b/test/async-hooks/test-graph.http.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasIPv6) diff --git a/test/async-hooks/test-graph.intervals.js b/test/async-hooks/test-graph.intervals.js index 9e626951a14b..b41319b6c31b 100644 --- a/test/async-hooks/test-graph.intervals.js +++ b/test/async-hooks/test-graph.intervals.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-graph.pipe.js b/test/async-hooks/test-graph.pipe.js index abf8a98ff00e..c9e1ec46996a 100644 --- a/test/async-hooks/test-graph.pipe.js +++ b/test/async-hooks/test-graph.pipe.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-graph.pipeconnect.js b/test/async-hooks/test-graph.pipeconnect.js index db237ff6b2d0..8b78dbc7255f 100644 --- a/test/async-hooks/test-graph.pipeconnect.js +++ b/test/async-hooks/test-graph.pipeconnect.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-graph.shutdown.js b/test/async-hooks/test-graph.shutdown.js index 0f633787e5e5..01fb4e157ed9 100644 --- a/test/async-hooks/test-graph.shutdown.js +++ b/test/async-hooks/test-graph.shutdown.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasIPv6) diff --git a/test/async-hooks/test-graph.signal.js b/test/async-hooks/test-graph.signal.js index 351fb7550af4..986a86ac696a 100644 --- a/test/async-hooks/test-graph.signal.js +++ b/test/async-hooks/test-graph.signal.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (common.isWindows) { diff --git a/test/async-hooks/test-graph.statwatcher.js b/test/async-hooks/test-graph.statwatcher.js index f960ffebd3eb..6416f982b03d 100644 --- a/test/async-hooks/test-graph.statwatcher.js +++ b/test/async-hooks/test-graph.statwatcher.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks require('../common'); const commonPath = require.resolve('../common'); diff --git a/test/async-hooks/test-graph.tcp.js b/test/async-hooks/test-graph.tcp.js index 6f8db20add68..252f98e2545f 100644 --- a/test/async-hooks/test-graph.tcp.js +++ b/test/async-hooks/test-graph.tcp.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasIPv6) diff --git a/test/async-hooks/test-graph.timeouts.js b/test/async-hooks/test-graph.timeouts.js index 88350db2bae8..51a3e4e245c2 100644 --- a/test/async-hooks/test-graph.timeouts.js +++ b/test/async-hooks/test-graph.timeouts.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-graph.tls-write-12.js b/test/async-hooks/test-graph.tls-write-12.js index 748234402c0e..487931d2cca6 100644 --- a/test/async-hooks/test-graph.tls-write-12.js +++ b/test/async-hooks/test-graph.tls-write-12.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; const common = require('../common'); diff --git a/test/async-hooks/test-graph.tls-write.js b/test/async-hooks/test-graph.tls-write.js index 243039e01d11..cefc5a5d5441 100644 --- a/test/async-hooks/test-graph.tls-write.js +++ b/test/async-hooks/test-graph.tls-write.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) diff --git a/test/async-hooks/test-http-agent-handle-reuse-parallel.js b/test/async-hooks/test-http-agent-handle-reuse-parallel.js index 3827691cc8bc..13a74013b73f 100644 --- a/test/async-hooks/test-http-agent-handle-reuse-parallel.js +++ b/test/async-hooks/test-http-agent-handle-reuse-parallel.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const initHooks = require('./init-hooks'); const { checkInvocations } = require('./hook-checks'); diff --git a/test/async-hooks/test-http-agent-handle-reuse-serial.js b/test/async-hooks/test-http-agent-handle-reuse-serial.js index bae0698a0a6b..0b191512bb2e 100644 --- a/test/async-hooks/test-http-agent-handle-reuse-serial.js +++ b/test/async-hooks/test-http-agent-handle-reuse-serial.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const initHooks = require('./init-hooks'); const { checkInvocations } = require('./hook-checks'); diff --git a/test/async-hooks/test-httpparser-reuse.js b/test/async-hooks/test-httpparser-reuse.js index f7ce2cd87622..c503b6fea47a 100644 --- a/test/async-hooks/test-httpparser-reuse.js +++ b/test/async-hooks/test-httpparser-reuse.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-httpparser.request.js b/test/async-hooks/test-httpparser.request.js index 6379bf330d23..fe0c000a325c 100644 --- a/test/async-hooks/test-httpparser.request.js +++ b/test/async-hooks/test-httpparser.request.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals --no-warnings +// Flags: --allow-async-hooks --expose-internals --no-warnings 'use strict'; diff --git a/test/async-hooks/test-httpparser.response.js b/test/async-hooks/test-httpparser.response.js index 2e600b127475..db1c3e0bdd81 100644 --- a/test/async-hooks/test-httpparser.response.js +++ b/test/async-hooks/test-httpparser.response.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals --no-warnings +// Flags: --allow-async-hooks --expose-internals --no-warnings 'use strict'; diff --git a/test/async-hooks/test-immediate.js b/test/async-hooks/test-immediate.js index fa9475abaed2..6aa54d3f8c67 100644 --- a/test/async-hooks/test-immediate.js +++ b/test/async-hooks/test-immediate.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-improper-order.js b/test/async-hooks/test-improper-order.js index 47678fb19777..76930205aebf 100644 --- a/test/async-hooks/test-improper-order.js +++ b/test/async-hooks/test-improper-order.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); @@ -41,7 +41,7 @@ if (process.argv[2] === 'child') { emitAfter(asyncId); } } else { - const args = ['--expose-internals'] + const args = ['--allow-async-hooks', '--expose-internals'] .concat(process.argv.slice(1)) .concat('child'); let errData = Buffer.from(''); diff --git a/test/async-hooks/test-improper-unwind.js b/test/async-hooks/test-improper-unwind.js index 9e651b3bc50f..134d9081df97 100644 --- a/test/async-hooks/test-improper-unwind.js +++ b/test/async-hooks/test-improper-unwind.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); @@ -45,7 +45,7 @@ if (process.argv[2] === 'child') { console.log('heartbeat: still alive'); emitAfter(eventOneId); } else { - const args = ['--expose-internals'] + const args = ['--allow-async-hooks', '--expose-internals'] .concat(process.argv.slice(1)) .concat('child'); let errData = Buffer.from(''); diff --git a/test/async-hooks/test-late-hook-enable.js b/test/async-hooks/test-late-hook-enable.js index 3305a05065b6..cdecc06aa113 100644 --- a/test/async-hooks/test-late-hook-enable.js +++ b/test/async-hooks/test-late-hook-enable.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/async-hooks/test-nexttick-default-trigger.js b/test/async-hooks/test-nexttick-default-trigger.js index fa1ad2c561ce..0af85c89b413 100644 --- a/test/async-hooks/test-nexttick-default-trigger.js +++ b/test/async-hooks/test-nexttick-default-trigger.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); // This tests ensures that the triggerId of the nextTick function sets the diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js index 36980f018598..90e403df5836 100644 --- a/test/async-hooks/test-pipeconnectwrap.js +++ b/test/async-hooks/test-pipeconnectwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-pipewrap.js b/test/async-hooks/test-pipewrap.js index 7ea5f38adc85..448a012ec891 100644 --- a/test/async-hooks/test-pipewrap.js +++ b/test/async-hooks/test-pipewrap.js @@ -1,7 +1,7 @@ // NOTE: this also covers process wrap as one is created along with the pipes // when we launch the sleep process 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js index f292c8286572..abdbf65a681c 100644 --- a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js +++ b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-promise.js b/test/async-hooks/test-promise.js index 96be5e5efcb4..4a9fe59e42c3 100644 --- a/test/async-hooks/test-promise.js +++ b/test/async-hooks/test-promise.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); diff --git a/test/async-hooks/test-promise.promise-before-init-hooks.js b/test/async-hooks/test-promise.promise-before-init-hooks.js index b61a214f4289..20293d1b1ef3 100644 --- a/test/async-hooks/test-promise.promise-before-init-hooks.js +++ b/test/async-hooks/test-promise.promise-before-init-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-querywrap.js b/test/async-hooks/test-querywrap.js index 5ddb2fe700ef..03559f7dbd08 100644 --- a/test/async-hooks/test-querywrap.js +++ b/test/async-hooks/test-querywrap.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-queue-microtask.js b/test/async-hooks/test-queue-microtask.js index 01200d454239..0168bb56dcdc 100644 --- a/test/async-hooks/test-queue-microtask.js +++ b/test/async-hooks/test-queue-microtask.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-shutdownwrap.js b/test/async-hooks/test-shutdownwrap.js index fea4a3a166a2..72b962d9bdf6 100644 --- a/test/async-hooks/test-shutdownwrap.js +++ b/test/async-hooks/test-shutdownwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js index 60adaedd476f..b59a75507792 100644 --- a/test/async-hooks/test-signalwrap.js +++ b/test/async-hooks/test-signalwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (common.isWindows) { diff --git a/test/async-hooks/test-statwatcher.js b/test/async-hooks/test-statwatcher.js index d24aab584029..2c44a5556d56 100644 --- a/test/async-hooks/test-statwatcher.js +++ b/test/async-hooks/test-statwatcher.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/async-hooks/test-tcpwrap.js b/test/async-hooks/test-tcpwrap.js index 3f0987b98822..52732dc246bc 100644 --- a/test/async-hooks/test-tcpwrap.js +++ b/test/async-hooks/test-tcpwrap.js @@ -1,5 +1,6 @@ // Covers TCPWRAP and related TCPCONNECTWRAP 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasIPv6) diff --git a/test/async-hooks/test-timers.setInterval.js b/test/async-hooks/test-timers.setInterval.js index 10b2bafb2a25..3c1c06f1f6af 100644 --- a/test/async-hooks/test-timers.setInterval.js +++ b/test/async-hooks/test-timers.setInterval.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-timers.setTimeout.js b/test/async-hooks/test-timers.setTimeout.js index 540c88abade3..1c546fbb2e8f 100644 --- a/test/async-hooks/test-timers.setTimeout.js +++ b/test/async-hooks/test-timers.setTimeout.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-tlswrap.js b/test/async-hooks/test-tlswrap.js index 6a8996e00f2b..c4e594987ae4 100644 --- a/test/async-hooks/test-tlswrap.js +++ b/test/async-hooks/test-tlswrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) diff --git a/test/async-hooks/test-track-promises-default.js b/test/async-hooks/test-track-promises-default.js index 071f8faaecc7..f76e0e4fb5c3 100644 --- a/test/async-hooks/test-track-promises-default.js +++ b/test/async-hooks/test-track-promises-default.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; // Test that trackPromises default to true. const common = require('../common'); diff --git a/test/async-hooks/test-track-promises-false-check.js b/test/async-hooks/test-track-promises-false-check.js index 7ff4142d0d1f..e2257698437a 100644 --- a/test/async-hooks/test-track-promises-false-check.js +++ b/test/async-hooks/test-track-promises-false-check.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; // Test that trackPromises: false prevents promise hooks from being installed. diff --git a/test/async-hooks/test-track-promises-false.js b/test/async-hooks/test-track-promises-false.js index 1a3b5eda2e2f..951441a88377 100644 --- a/test/async-hooks/test-track-promises-false.js +++ b/test/async-hooks/test-track-promises-false.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; // Test that trackPromises: false works. const common = require('../common'); diff --git a/test/async-hooks/test-track-promises-true.js b/test/async-hooks/test-track-promises-true.js index cc53f3a9c926..41e6acdd9e28 100644 --- a/test/async-hooks/test-track-promises-true.js +++ b/test/async-hooks/test-track-promises-true.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; // Test that trackPromises: true works. const common = require('../common'); diff --git a/test/async-hooks/test-track-promises-validation.js b/test/async-hooks/test-track-promises-validation.js index 108f82ff2562..9e2a381ccf7b 100644 --- a/test/async-hooks/test-track-promises-validation.js +++ b/test/async-hooks/test-track-promises-validation.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; // Test validation of trackPromises option. diff --git a/test/async-hooks/test-ttywrap.readstream.js b/test/async-hooks/test-ttywrap.readstream.js index 7e27ffc5bfb2..b46e7a2855e1 100644 --- a/test/async-hooks/test-ttywrap.readstream.js +++ b/test/async-hooks/test-ttywrap.readstream.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-udpsendwrap.js b/test/async-hooks/test-udpsendwrap.js index f1403e3226a1..76909cc4951e 100644 --- a/test/async-hooks/test-udpsendwrap.js +++ b/test/async-hooks/test-udpsendwrap.js @@ -1,4 +1,4 @@ -// Flags: --test-udp-no-try-send +// Flags: --allow-async-hooks --test-udp-no-try-send 'use strict'; const common = require('../common'); diff --git a/test/async-hooks/test-udpwrap.js b/test/async-hooks/test-udpwrap.js index 0a0e03c5d514..63773b2cb137 100644 --- a/test/async-hooks/test-udpwrap.js +++ b/test/async-hooks/test-udpwrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-unhandled-exception-valid-ids.js b/test/async-hooks/test-unhandled-exception-valid-ids.js index 09e5823452fd..a88922252efa 100644 --- a/test/async-hooks/test-unhandled-exception-valid-ids.js +++ b/test/async-hooks/test-unhandled-exception-valid-ids.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const initHooks = require('./init-hooks'); diff --git a/test/async-hooks/test-unhandled-rejection-context.js b/test/async-hooks/test-unhandled-rejection-context.js index 168b51a3331f..533036c28da1 100644 --- a/test/async-hooks/test-unhandled-rejection-context.js +++ b/test/async-hooks/test-unhandled-rejection-context.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); diff --git a/test/async-hooks/test-writewrap.js b/test/async-hooks/test-writewrap.js index 4f3455480ba8..c6075220d1cb 100644 --- a/test/async-hooks/test-writewrap.js +++ b/test/async-hooks/test-writewrap.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/async-hooks/test-zlib.zlib-binding.deflate.js b/test/async-hooks/test-zlib.zlib-binding.deflate.js index 802f09eb306c..66614a811afd 100644 --- a/test/async-hooks/test-zlib.zlib-binding.deflate.js +++ b/test/async-hooks/test-zlib.zlib-binding.deflate.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/es-module/test-vm-compile-function-leak.js b/test/es-module/test-vm-compile-function-leak.js index f9f04588fdc7..97f7bb78c040 100644 --- a/test/es-module/test-vm-compile-function-leak.js +++ b/test/es-module/test-vm-compile-function-leak.js @@ -1,4 +1,4 @@ -// Flags: --max-old-space-size=16 --trace-gc +// Flags: --allow-async-hooks --max-old-space-size=16 --trace-gc 'use strict'; // This tests that vm.compileFunction with dynamic import callback does not leak. diff --git a/test/es-module/test-vm-contextified-script-leak.js b/test/es-module/test-vm-contextified-script-leak.js index a8625fc94d24..4370b8235ec8 100644 --- a/test/es-module/test-vm-contextified-script-leak.js +++ b/test/es-module/test-vm-contextified-script-leak.js @@ -1,4 +1,4 @@ -// Flags: --max-old-space-size=16 --trace-gc +// Flags: --allow-async-hooks --max-old-space-size=16 --trace-gc 'use strict'; // This tests that vm.Script with dynamic import callback does not leak. diff --git a/test/es-module/test-vm-source-text-module-leak.js b/test/es-module/test-vm-source-text-module-leak.js index ad85c08e3937..4d6901fc7b64 100644 --- a/test/es-module/test-vm-source-text-module-leak.js +++ b/test/es-module/test-vm-source-text-module-leak.js @@ -1,4 +1,4 @@ -// Flags: --experimental-vm-modules --max-old-space-size=16 --trace-gc +// Flags: --allow-async-hooks --experimental-vm-modules --max-old-space-size=16 --trace-gc 'use strict'; // This tests that vm.SourceTextModule() does not leak. diff --git a/test/es-module/test-vm-synthetic-module-leak.js b/test/es-module/test-vm-synthetic-module-leak.js index bc0e46895353..267d3aa590b7 100644 --- a/test/es-module/test-vm-synthetic-module-leak.js +++ b/test/es-module/test-vm-synthetic-module-leak.js @@ -1,4 +1,4 @@ -// Flags: --experimental-vm-modules --max-old-space-size=16 +// Flags: --allow-async-hooks --experimental-vm-modules --max-old-space-size=16 'use strict'; // This tests that vm.SyntheticModule does not leak. diff --git a/test/node-api/test_async/test-async-hooks.js b/test/node-api/test_async/test-async-hooks.js index 956d210f3f08..3dd533e51ad7 100644 --- a/test/node-api/test_async/test-async-hooks.js +++ b/test/node-api/test_async/test-async-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/node-api/test_async_context/test-gcable-callback.js b/test/node-api/test_async_context/test-gcable-callback.js index b1e4d29c5f41..e57ebe31e291 100644 --- a/test/node-api/test_async_context/test-gcable-callback.js +++ b/test/node-api/test_async_context/test-gcable-callback.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --gc-interval=100 --gc-global +// Flags: --allow-async-hooks --gc-interval=100 --gc-global const common = require('../../common'); const assert = require('assert'); diff --git a/test/node-api/test_async_context/test.js b/test/node-api/test_async_context/test.js index e4e46afbf2eb..d4597395f911 100644 --- a/test/node-api/test_async_context/test.js +++ b/test/node-api/test_async_context/test.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --gc-interval=100 --gc-global +// Flags: --allow-async-hooks --gc-interval=100 --gc-global const common = require('../../common'); const assert = require('assert'); diff --git a/test/node-api/test_callback_scope/test-async-hooks.js b/test/node-api/test_callback_scope/test-async-hooks.js index 7c12e25848d0..a8ef13135f5c 100644 --- a/test/node-api/test_callback_scope/test-async-hooks.js +++ b/test/node-api/test_callback_scope/test-async-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../../common'); const assert = require('assert'); diff --git a/test/node-api/test_make_callback/test-async-hooks.js b/test/node-api/test_make_callback/test-async-hooks.js index d6053c5058a1..4603e86b4498 100644 --- a/test/node-api/test_make_callback/test-async-hooks.js +++ b/test/node-api/test_make_callback/test-async-hooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../../common'); const assert = require('assert'); diff --git a/test/parallel/test-async-hooks-async-await.js b/test/parallel/test-async-hooks-async-await.js index 97b50f3f2685..e8f21c642474 100644 --- a/test/parallel/test-async-hooks-async-await.js +++ b/test/parallel/test-async-hooks-async-await.js @@ -1,6 +1,7 @@ // Test async-hooks fired on right // asyncIds & triggerAsyncId for async-await 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-asyncresource-constructor.js b/test/parallel/test-async-hooks-asyncresource-constructor.js index 8b504aa7a79e..b8d7e2bcfd44 100644 --- a/test/parallel/test-async-hooks-asyncresource-constructor.js +++ b/test/parallel/test-async-hooks-asyncresource-constructor.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // This tests that AsyncResource throws an error if bad parameters are passed diff --git a/test/parallel/test-async-hooks-close-during-destroy.js b/test/parallel/test-async-hooks-close-during-destroy.js index 6e485d2d1110..414bf5a2a26d 100644 --- a/test/parallel/test-async-hooks-close-during-destroy.js +++ b/test/parallel/test-async-hooks-close-during-destroy.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // Test that async ids that are added to the destroy queue while running a // `destroy` callback are handled correctly. diff --git a/test/parallel/test-async-hooks-constructor.js b/test/parallel/test-async-hooks-constructor.js index 62ec854108e9..aa67f1fe68f9 100644 --- a/test/parallel/test-async-hooks-constructor.js +++ b/test/parallel/test-async-hooks-constructor.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // This tests that AsyncHooks throws an error if bad parameters are passed. diff --git a/test/parallel/test-async-hooks-correctly-switch-promise-hook.js b/test/parallel/test-async-hooks-correctly-switch-promise-hook.js index 73127f1ebaf9..e1b6c00d558c 100644 --- a/test/parallel/test-async-hooks-correctly-switch-promise-hook.js +++ b/test/parallel/test-async-hooks-correctly-switch-promise-hook.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-create-hook-disabled-internals.js b/test/parallel/test-async-hooks-create-hook-disabled-internals.js new file mode 100644 index 000000000000..4e8a4d8721fa --- /dev/null +++ b/test/parallel/test-async-hooks-create-hook-disabled-internals.js @@ -0,0 +1,22 @@ +'use strict'; + +// Node.js internals that rely on async hooks must keep working without +// --allow-async-hooks. + +const common = require('../common'); +const assert = require('assert'); +const { spawnSync } = require('child_process'); +const test = require('node:test'); + +test('node:test runs without --allow-async-hooks', common.mustCall()); + +{ + const tmpdir = require('../common/tmpdir'); + tmpdir.refresh(); + const child = spawnSync(process.execPath, [ + '--trace-event-categories', 'node.async_hooks', + '-e', 'setTimeout(() => {}, 1)', + ], { cwd: tmpdir.path, encoding: 'utf8' }); + assert.strictEqual(child.stderr, ''); + assert.strictEqual(child.status, 0); +} diff --git a/test/parallel/test-async-hooks-create-hook-disabled.js b/test/parallel/test-async-hooks-create-hook-disabled.js new file mode 100644 index 000000000000..e8b62f23f572 --- /dev/null +++ b/test/parallel/test-async-hooks-create-hook-disabled.js @@ -0,0 +1,15 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const { createHook } = require('async_hooks'); + +// async_hooks.createHook is disabled by default (without --allow-async-hooks) +{ + assert.throws(() => { + createHook({ init() {} }); + }, common.expectsError({ + code: 'ERR_ASYNC_HOOKS_CREATE_HOOK_DISABLED', + message: 'async_hooks.createHook() is disabled. Use --allow-async-hooks to enable it.', + })); +} diff --git a/test/parallel/test-async-hooks-create-hook-enabled.js b/test/parallel/test-async-hooks-create-hook-enabled.js new file mode 100644 index 000000000000..1583a5bd10ba --- /dev/null +++ b/test/parallel/test-async-hooks-create-hook-enabled.js @@ -0,0 +1,18 @@ +// Flags: --allow-async-hooks +'use strict'; + +require('../common'); +const { createHook } = require('async_hooks'); + +// When --allow-async-hooks is passed, createHook should work +{ + // doesNotThrow + const hook = createHook({ + init() {}, + before() {}, + after() {}, + destroy() {}, + }); + hook.enable(); + hook.disable(); +} diff --git a/test/parallel/test-async-hooks-destroy-on-gc.js b/test/parallel/test-async-hooks-destroy-on-gc.js index a401f6651ccc..d4feaca508b2 100644 --- a/test/parallel/test-async-hooks-destroy-on-gc.js +++ b/test/parallel/test-async-hooks-destroy-on-gc.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose_gc +// Flags: --allow-async-hooks --expose_gc // This test ensures that userland-only AsyncResources cause a destroy event to // be emitted when they get gced. diff --git a/test/parallel/test-async-hooks-disable-during-promise.js b/test/parallel/test-async-hooks-disable-during-promise.js index a25dae51e1f8..fddd65d0b6a7 100644 --- a/test/parallel/test-async-hooks-disable-during-promise.js +++ b/test/parallel/test-async-hooks-disable-during-promise.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); const { isMainThread } = require('worker_threads'); diff --git a/test/parallel/test-async-hooks-disable-gc-tracking.js b/test/parallel/test-async-hooks-disable-gc-tracking.js index 87b096c25812..597dfb1fbb17 100644 --- a/test/parallel/test-async-hooks-disable-gc-tracking.js +++ b/test/parallel/test-async-hooks-disable-gc-tracking.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose_gc +// Flags: --allow-async-hooks --expose_gc // This test ensures that userland-only AsyncResources cause a destroy event to // be emitted when they get gced. diff --git a/test/parallel/test-async-hooks-enable-before-promise-resolve.js b/test/parallel/test-async-hooks-enable-before-promise-resolve.js index e6facfb6392e..02632caf51e8 100644 --- a/test/parallel/test-async-hooks-enable-before-promise-resolve.js +++ b/test/parallel/test-async-hooks-enable-before-promise-resolve.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-enable-disable-enable.js b/test/parallel/test-async-hooks-enable-disable-enable.js index 640815e14c8c..9d477690221e 100644 --- a/test/parallel/test-async-hooks-enable-disable-enable.js +++ b/test/parallel/test-async-hooks-enable-disable-enable.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-enable-disable.js b/test/parallel/test-async-hooks-enable-disable.js index 71d35c91371f..0da1421b675b 100644 --- a/test/parallel/test-async-hooks-enable-disable.js +++ b/test/parallel/test-async-hooks-enable-disable.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-enable-during-promise.js b/test/parallel/test-async-hooks-enable-during-promise.js index ce3253b01c12..6cf0469819ae 100644 --- a/test/parallel/test-async-hooks-enable-during-promise.js +++ b/test/parallel/test-async-hooks-enable-during-promise.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-enable-recursive.js b/test/parallel/test-async-hooks-enable-recursive.js index 74caebbad225..76382c1c69ac 100644 --- a/test/parallel/test-async-hooks-enable-recursive.js +++ b/test/parallel/test-async-hooks-enable-recursive.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-enabledhooksexits.js b/test/parallel/test-async-hooks-enabledhooksexits.js index 11737d65485b..8ffa719352fd 100644 --- a/test/parallel/test-async-hooks-enabledhooksexits.js +++ b/test/parallel/test-async-hooks-enabledhooksexits.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; require('../common'); diff --git a/test/parallel/test-async-hooks-execution-async-resource-await.js b/test/parallel/test-async-hooks-execution-async-resource-await.js index 8dc04c83d731..e2007612a2a3 100644 --- a/test/parallel/test-async-hooks-execution-async-resource-await.js +++ b/test/parallel/test-async-hooks-execution-async-resource-await.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const sleep = require('util').promisify(setTimeout); diff --git a/test/parallel/test-async-hooks-execution-async-resource.js b/test/parallel/test-async-hooks-execution-async-resource.js index b3a9f76ef4ec..026ef5c28ff1 100644 --- a/test/parallel/test-async-hooks-execution-async-resource.js +++ b/test/parallel/test-async-hooks-execution-async-resource.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-async-hooks-fatal-error.js b/test/parallel/test-async-hooks-fatal-error.js index 30ead86132f6..12ba8fdc1262 100644 --- a/test/parallel/test-async-hooks-fatal-error.js +++ b/test/parallel/test-async-hooks-fatal-error.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const childProcess = require('child_process'); @@ -41,7 +42,7 @@ function main() { for (const [valueType, expect] of valueTypes) { const cp = childProcess.spawnSync( process.execPath, - [ __filename, 'child', type, valueType ], + [ '--allow-async-hooks', __filename, 'child', type, valueType ], { encoding: 'utf8', }); diff --git a/test/parallel/test-async-hooks-http-agent-destroy.js b/test/parallel/test-async-hooks-http-agent-destroy.js index 4d90cb7d3507..bcf6b95a721f 100644 --- a/test/parallel/test-async-hooks-http-agent-destroy.js +++ b/test/parallel/test-async-hooks-http-agent-destroy.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const assert = require('assert'); const { async_id_symbol } = require('internal/async_hooks').symbols; diff --git a/test/parallel/test-async-hooks-http-agent.js b/test/parallel/test-async-hooks-http-agent.js index 337bab65d9df..fae327f4fad7 100644 --- a/test/parallel/test-async-hooks-http-agent.js +++ b/test/parallel/test-async-hooks-http-agent.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals const common = require('../common'); const assert = require('assert'); const { async_id_symbol } = require('internal/async_hooks').symbols; diff --git a/test/parallel/test-async-hooks-http-parser-destroy.js b/test/parallel/test-async-hooks-http-parser-destroy.js index b2d1fd9a94f1..212784efb199 100644 --- a/test/parallel/test-async-hooks-http-parser-destroy.js +++ b/test/parallel/test-async-hooks-http-parser-destroy.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-prevent-double-destroy.js b/test/parallel/test-async-hooks-prevent-double-destroy.js index 4aa55a5a6c87..9205f4c4f071 100644 --- a/test/parallel/test-async-hooks-prevent-double-destroy.js +++ b/test/parallel/test-async-hooks-prevent-double-destroy.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose_gc +// Flags: --allow-async-hooks --expose_gc // This test ensures that userland-only AsyncResources cause a destroy event to // be emitted when they get gced. diff --git a/test/parallel/test-async-hooks-promise-enable-disable.js b/test/parallel/test-async-hooks-promise-enable-disable.js index 92504ac121e5..4209a213ac41 100644 --- a/test/parallel/test-async-hooks-promise-enable-disable.js +++ b/test/parallel/test-async-hooks-promise-enable-disable.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-async-hooks-promise-triggerid.js b/test/parallel/test-async-hooks-promise-triggerid.js index 89e5bc1464f8..60db4ade10fd 100644 --- a/test/parallel/test-async-hooks-promise-triggerid.js +++ b/test/parallel/test-async-hooks-promise-triggerid.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-promise.js b/test/parallel/test-async-hooks-promise.js index 74f72a188240..4261edc34f21 100644 --- a/test/parallel/test-async-hooks-promise.js +++ b/test/parallel/test-async-hooks-promise.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-recursive-stack-runInAsyncScope.js b/test/parallel/test-async-hooks-recursive-stack-runInAsyncScope.js index d0d5ee76e9d1..64c31f576ebb 100644 --- a/test/parallel/test-async-hooks-recursive-stack-runInAsyncScope.js +++ b/test/parallel/test-async-hooks-recursive-stack-runInAsyncScope.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js b/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js index e38cefd20e4f..78bf7b488ee9 100644 --- a/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js +++ b/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks require('../common'); const { AsyncResource } = require('async_hooks'); diff --git a/test/parallel/test-async-hooks-run-in-async-scope-this-arg.js b/test/parallel/test-async-hooks-run-in-async-scope-this-arg.js index a5016da9d5fc..e6456b8f0190 100644 --- a/test/parallel/test-async-hooks-run-in-async-scope-this-arg.js +++ b/test/parallel/test-async-hooks-run-in-async-scope-this-arg.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // Test that passing thisArg to runInAsyncScope() works. diff --git a/test/parallel/test-async-hooks-stack-overflow-nested-async.js b/test/parallel/test-async-hooks-stack-overflow-nested-async.js index 779f8d75ae20..2cd3cc8abc06 100644 --- a/test/parallel/test-async-hooks-stack-overflow-nested-async.js +++ b/test/parallel/test-async-hooks-stack-overflow-nested-async.js @@ -66,7 +66,7 @@ if (process.argv[2] === 'child') { // Parent process - spawn the child and check exit code const result = spawnSync( process.execPath, - [__filename, 'child'], + ['--allow-async-hooks', __filename, 'child'], { encoding: 'utf8', timeout: 30000 } ); diff --git a/test/parallel/test-async-hooks-stack-overflow-try-catch.js b/test/parallel/test-async-hooks-stack-overflow-try-catch.js index 43338905e78b..2cd199a5aa01 100644 --- a/test/parallel/test-async-hooks-stack-overflow-try-catch.js +++ b/test/parallel/test-async-hooks-stack-overflow-try-catch.js @@ -35,7 +35,7 @@ if (process.argv[2] === 'child') { // Parent process - spawn the child and check exit code const result = spawnSync( process.execPath, - [__filename, 'child'], + ['--allow-async-hooks', __filename, 'child'], { encoding: 'utf8', timeout: 30000 } ); diff --git a/test/parallel/test-async-hooks-stack-overflow.js b/test/parallel/test-async-hooks-stack-overflow.js index aff41969dbdf..6b0d2b3aec4c 100644 --- a/test/parallel/test-async-hooks-stack-overflow.js +++ b/test/parallel/test-async-hooks-stack-overflow.js @@ -34,7 +34,7 @@ if (process.argv[2] === 'child') { // Parent process - spawn the child and check exit code const result = spawnSync( process.execPath, - [__filename, 'child'], + ['--allow-async-hooks', __filename, 'child'], { encoding: 'utf8', timeout: 30000 } ); diff --git a/test/parallel/test-async-hooks-top-level-clearimmediate.js b/test/parallel/test-async-hooks-top-level-clearimmediate.js index fd91fefa9c4b..30950c4f3c71 100644 --- a/test/parallel/test-async-hooks-top-level-clearimmediate.js +++ b/test/parallel/test-async-hooks-top-level-clearimmediate.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // Regression test for https://github.com/nodejs/node/issues/13262 diff --git a/test/parallel/test-async-hooks-vm-gc.js b/test/parallel/test-async-hooks-vm-gc.js index da95e3579dcc..220b5788500a 100644 --- a/test/parallel/test-async-hooks-vm-gc.js +++ b/test/parallel/test-async-hooks-vm-gc.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc 'use strict'; require('../common'); diff --git a/test/parallel/test-async-hooks-worker-asyncfn-terminate-1.js b/test/parallel/test-async-hooks-worker-asyncfn-terminate-1.js index eb1664591308..fc2790357ad0 100644 --- a/test/parallel/test-async-hooks-worker-asyncfn-terminate-1.js +++ b/test/parallel/test-async-hooks-worker-asyncfn-terminate-1.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js b/test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js index 049264d3e8ae..70966c3b4078 100644 --- a/test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js +++ b/test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js b/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js index 40c7d85835ae..10b17ab81e6d 100644 --- a/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js +++ b/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-async-hooks-worker-asyncfn-terminate-4.js b/test/parallel/test-async-hooks-worker-asyncfn-terminate-4.js index c522091006cf..17475418eba0 100644 --- a/test/parallel/test-async-hooks-worker-asyncfn-terminate-4.js +++ b/test/parallel/test-async-hooks-worker-asyncfn-terminate-4.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-async-local-storage-http-parser-leak.js b/test/parallel/test-async-local-storage-http-parser-leak.js index b55aed8717ab..0b7dcefad479 100644 --- a/test/parallel/test-async-local-storage-http-parser-leak.js +++ b/test/parallel/test-async-local-storage-http-parser-leak.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc --expose-internals +// Flags: --allow-async-hooks --expose-gc --expose-internals 'use strict'; diff --git a/test/parallel/test-async-wrap-constructor.js b/test/parallel/test-async-wrap-constructor.js index 853898aa0adf..32c966ad8ba0 100644 --- a/test/parallel/test-async-wrap-constructor.js +++ b/test/parallel/test-async-wrap-constructor.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // This tests that using falsy values in createHook throws an error. diff --git a/test/parallel/test-async-wrap-destroyid.js b/test/parallel/test-async-wrap-destroyid.js index 25a33246e775..91c04c02a7a4 100644 --- a/test/parallel/test-async-wrap-destroyid.js +++ b/test/parallel/test-async-wrap-destroyid.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-async-wrap-pop-id-during-load.js b/test/parallel/test-async-wrap-pop-id-during-load.js index bd53c4d7893d..4b620ae93566 100644 --- a/test/parallel/test-async-wrap-pop-id-during-load.js +++ b/test/parallel/test-async-wrap-pop-id-during-load.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks require('../common'); diff --git a/test/parallel/test-async-wrap-promise-after-enabled.js b/test/parallel/test-async-wrap-promise-after-enabled.js index fafb732c2895..dc0ad12b97fe 100644 --- a/test/parallel/test-async-wrap-promise-after-enabled.js +++ b/test/parallel/test-async-wrap-promise-after-enabled.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks // Regression test for https://github.com/nodejs/node/issues/13237 diff --git a/test/parallel/test-async-wrap-tlssocket-asyncreset.js b/test/parallel/test-async-wrap-tlssocket-asyncreset.js index 513911978b1d..8f1a47695723 100644 --- a/test/parallel/test-async-wrap-tlssocket-asyncreset.js +++ b/test/parallel/test-async-wrap-tlssocket-asyncreset.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const fixtures = require('../common/fixtures'); diff --git a/test/parallel/test-async-wrap-trigger-id.js b/test/parallel/test-async-wrap-trigger-id.js index e8b4682b7167..0d922a99ae18 100644 --- a/test/parallel/test-async-wrap-trigger-id.js +++ b/test/parallel/test-async-wrap-trigger-id.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-async-wrap-uncaughtexception.js b/test/parallel/test-async-wrap-uncaughtexception.js index 37557b4aacc3..83b34d7c3e79 100644 --- a/test/parallel/test-async-wrap-uncaughtexception.js +++ b/test/parallel/test-async-wrap-uncaughtexception.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) diff --git a/test/parallel/test-common-gc.js b/test/parallel/test-common-gc.js index 54abe3695cc3..78c771ba1b1f 100644 --- a/test/parallel/test-common-gc.js +++ b/test/parallel/test-common-gc.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const { onGC } = require('../common/gc'); diff --git a/test/parallel/test-diagnostics-channel-memory-leak.js b/test/parallel/test-diagnostics-channel-memory-leak.js index 06301847ed6b..f010209220c7 100644 --- a/test/parallel/test-diagnostics-channel-memory-leak.js +++ b/test/parallel/test-diagnostics-channel-memory-leak.js @@ -1,4 +1,4 @@ -// Flags: --max-old-space-size=16 +// Flags: --allow-async-hooks --max-old-space-size=16 'use strict'; // This test ensures that diagnostic channel references aren't leaked. diff --git a/test/parallel/test-emit-after-uncaught-exception.js b/test/parallel/test-emit-after-uncaught-exception.js index 5003972e9984..a219427aac11 100644 --- a/test/parallel/test-emit-after-uncaught-exception.js +++ b/test/parallel/test-emit-after-uncaught-exception.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-eventemitter-asyncresource.js b/test/parallel/test-eventemitter-asyncresource.js index fe7839a1bb23..e5995a0d37cd 100644 --- a/test/parallel/test-eventemitter-asyncresource.js +++ b/test/parallel/test-eventemitter-asyncresource.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { EventEmitterAsyncResource } = require('events'); diff --git a/test/parallel/test-fs-cp-async-destination-appears-late.mjs b/test/parallel/test-fs-cp-async-destination-appears-late.mjs index 40ec15e1ef39..1ac76f6e658d 100644 --- a/test/parallel/test-fs-cp-async-destination-appears-late.mjs +++ b/test/parallel/test-fs-cp-async-destination-appears-late.mjs @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks // This tests that cp() into a destination that did not exist when it was // checked, but does by the time the copy starts, fails with EEXIST instead // of copying through whatever appeared there. diff --git a/test/parallel/test-fs-existssync-memleak-longpath.js b/test/parallel/test-fs-existssync-memleak-longpath.js index 90617badc96d..7ab96dc523be 100644 --- a/test/parallel/test-fs-existssync-memleak-longpath.js +++ b/test/parallel/test-fs-existssync-memleak-longpath.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc --expose-internals +// Flags: --allow-async-hooks --expose-gc --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-fs-readfile-one-roundtrip.js b/test/parallel/test-fs-readfile-one-roundtrip.js index 87df04795d8d..bb6d9afa6417 100644 --- a/test/parallel/test-fs-readfile-one-roundtrip.js +++ b/test/parallel/test-fs-readfile-one-roundtrip.js @@ -1,3 +1,4 @@ +// Flags: --allow-async-hooks 'use strict'; // fs.readFile()/fs.promises.readFile() read files of up to one chunk // (512 KiB) with a single thread pool round trip and hand larger files over diff --git a/test/parallel/test-gc-http-client-connaborted.js b/test/parallel/test-gc-http-client-connaborted.js index e52a555d7880..ec491e50c883 100644 --- a/test/parallel/test-gc-http-client-connaborted.js +++ b/test/parallel/test-gc-http-client-connaborted.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // just like test-gc-http-client.js, // but aborting every connection that comes in. diff --git a/test/parallel/test-gc-net-timeout.js b/test/parallel/test-gc-net-timeout.js index 0fc93bfc62c2..c4dbbcbcd53f 100644 --- a/test/parallel/test-gc-net-timeout.js +++ b/test/parallel/test-gc-net-timeout.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // just like test-gc-http-client-timeout.js, // but using a net server/client instead diff --git a/test/parallel/test-gc-tls-external-memory.js b/test/parallel/test-gc-tls-external-memory.js index 480b1086b539..e82e82602d93 100644 --- a/test/parallel/test-gc-tls-external-memory.js +++ b/test/parallel/test-gc-tls-external-memory.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // Tests that memoryUsage().external doesn't go negative // when a lot tls connections are opened and closed diff --git a/test/parallel/test-heapdump-async-hooks-init-promise.js b/test/parallel/test-heapdump-async-hooks-init-promise.js index 80d6309deabd..1e0186234142 100644 --- a/test/parallel/test-heapdump-async-hooks-init-promise.js +++ b/test/parallel/test-heapdump-async-hooks-init-promise.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc 'use strict'; const common = require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-http-agent-domain-reused-gc.js b/test/parallel/test-http-agent-domain-reused-gc.js index 4f12c2ede839..82fea3e114a3 100644 --- a/test/parallel/test-http-agent-domain-reused-gc.js +++ b/test/parallel/test-http-agent-domain-reused-gc.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc --expose-internals +// Flags: --allow-async-hooks --expose-gc --expose-internals 'use strict'; const common = require('../common'); const http = require('http'); diff --git a/test/parallel/test-http-client-leaky-with-double-response.js b/test/parallel/test-http-client-leaky-with-double-response.js index a569b3bb31be..3595be1fbf8e 100644 --- a/test/parallel/test-http-client-leaky-with-double-response.js +++ b/test/parallel/test-http-client-leaky-with-double-response.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const http = require('http'); const assert = require('assert'); diff --git a/test/parallel/test-http-server-connections-checking-leak.js b/test/parallel/test-http-server-connections-checking-leak.js index 38dca83102cf..360e8f4d2342 100644 --- a/test/parallel/test-http-server-connections-checking-leak.js +++ b/test/parallel/test-http-server-connections-checking-leak.js @@ -1,6 +1,6 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // Check that creating a server without listening does not leak resources. diff --git a/test/parallel/test-http-server-keepalive-req-gc.js b/test/parallel/test-http-server-keepalive-req-gc.js index c827cd19ad72..c26f456554a1 100644 --- a/test/parallel/test-http-server-keepalive-req-gc.js +++ b/test/parallel/test-http-server-keepalive-req-gc.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc 'use strict'; const common = require('../common'); const { onGC } = require('../common/gc'); diff --git a/test/parallel/test-http-uncaught-from-request-callback.js b/test/parallel/test-http-uncaught-from-request-callback.js index 5c7595861789..3822846972f6 100644 --- a/test/parallel/test-http-uncaught-from-request-callback.js +++ b/test/parallel/test-http-uncaught-from-request-callback.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const asyncHooks = require('async_hooks'); const http = require('http'); diff --git a/test/parallel/test-http2-debug.js b/test/parallel/test-http2-debug.js index c7252317be3a..2a20d6988853 100644 --- a/test/parallel/test-http2-debug.js +++ b/test/parallel/test-http2-debug.js @@ -15,6 +15,7 @@ const stderrFile = tmpdir.resolve('stderr.log'); const stderrFd = fs.openSync(stderrFile, 'w'); try { spawnSyncAndAssert(process.execPath, [ + '--allow-async-hooks', path.resolve(__dirname, 'test-http2-ping.js'), ], { env: { diff --git a/test/parallel/test-http2-ping.js b/test/parallel/test-http2-ping.js index 90ef57e03ccf..333653fb4d1a 100644 --- a/test/parallel/test-http2-ping.js +++ b/test/parallel/test-http2-ping.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); if (!common.hasCrypto) diff --git a/test/parallel/test-https-server-connections-checking-leak.js b/test/parallel/test-https-server-connections-checking-leak.js index f79149ef70a9..f0d64f8105a9 100644 --- a/test/parallel/test-https-server-connections-checking-leak.js +++ b/test/parallel/test-https-server-connections-checking-leak.js @@ -1,6 +1,6 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // Check that creating a server without listening does not leak resources. diff --git a/test/parallel/test-inspector-contexts.js b/test/parallel/test-inspector-contexts.js index 9ab2c515b4a9..6e8a99c247f4 100644 --- a/test/parallel/test-inspector-contexts.js +++ b/test/parallel/test-inspector-contexts.js @@ -1,6 +1,6 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); common.skipIfInspectorDisabled(); diff --git a/test/parallel/test-inspector-debug-async-hook.js b/test/parallel/test-inspector-debug-async-hook.js index e8f13b40c7e4..2333a5240c8f 100644 --- a/test/parallel/test-inspector-debug-async-hook.js +++ b/test/parallel/test-inspector-debug-async-hook.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); common.skipIfInspectorDisabled(); const test = require('node:test'); diff --git a/test/parallel/test-internal-util-weakreference.js b/test/parallel/test-internal-util-weakreference.js index 0ecef956a44a..62f2900b0057 100644 --- a/test/parallel/test-internal-util-weakreference.js +++ b/test/parallel/test-internal-util-weakreference.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals --expose-gc +// Flags: --allow-async-hooks --expose-internals --expose-gc 'use strict'; require('../common'); const { gcUntil } = require('../common/gc'); diff --git a/test/parallel/test-messageport-hasref.js b/test/parallel/test-messageport-hasref.js index 563a598b3658..52cdfdb0419c 100644 --- a/test/parallel/test-messageport-hasref.js +++ b/test/parallel/test-messageport-hasref.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { MessageChannel } = require('worker_threads'); diff --git a/test/parallel/test-net-connect-memleak.js b/test/parallel/test-net-connect-memleak.js index de925f5d08c4..2fcd44a65168 100644 --- a/test/parallel/test-net-connect-memleak.js +++ b/test/parallel/test-net-connect-memleak.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const { onGC } = require('../common/gc'); diff --git a/test/parallel/test-primitive-timer-leak.js b/test/parallel/test-primitive-timer-leak.js index a0fe2765e128..1c9708c77068 100644 --- a/test/parallel/test-primitive-timer-leak.js +++ b/test/parallel/test-primitive-timer-leak.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc require('../common'); const { onGC } = require('../common/gc'); diff --git a/test/parallel/test-promise-hook-create-hook.js b/test/parallel/test-promise-hook-create-hook.js index 543f67da4860..8e3448a36134 100644 --- a/test/parallel/test-promise-hook-create-hook.js +++ b/test/parallel/test-promise-hook-create-hook.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const { promiseHooks } = require('v8'); diff --git a/test/parallel/test-queue-microtask-uncaught-asynchooks.js b/test/parallel/test-queue-microtask-uncaught-asynchooks.js index 35b3d9fa309a..8021cdeaba8f 100644 --- a/test/parallel/test-queue-microtask-uncaught-asynchooks.js +++ b/test/parallel/test-queue-microtask-uncaught-asynchooks.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); diff --git a/test/parallel/test-shadow-realm-gc-module.js b/test/parallel/test-shadow-realm-gc-module.js index 6077bf03146d..91434e7fdc0a 100644 --- a/test/parallel/test-shadow-realm-gc-module.js +++ b/test/parallel/test-shadow-realm-gc-module.js @@ -1,4 +1,4 @@ -// Flags: --experimental-shadow-realm --max-old-space-size=20 +// Flags: --allow-async-hooks --experimental-shadow-realm --max-old-space-size=20 'use strict'; /** diff --git a/test/parallel/test-shadow-realm-gc.js b/test/parallel/test-shadow-realm-gc.js index c6de4a32a88f..26e5c5798d94 100644 --- a/test/parallel/test-shadow-realm-gc.js +++ b/test/parallel/test-shadow-realm-gc.js @@ -1,4 +1,4 @@ -// Flags: --experimental-shadow-realm --max-old-space-size=20 +// Flags: --allow-async-hooks --experimental-shadow-realm --max-old-space-size=20 'use strict'; /** diff --git a/test/parallel/test-source-map-cjs-require-cache.js b/test/parallel/test-source-map-cjs-require-cache.js index 155b7a66efab..f066e3b6ec9d 100644 --- a/test/parallel/test-source-map-cjs-require-cache.js +++ b/test/parallel/test-source-map-cjs-require-cache.js @@ -1,4 +1,4 @@ -// Flags: --enable-source-maps --max-old-space-size=10 --expose-gc +// Flags: --allow-async-hooks --enable-source-maps --max-old-space-size=10 --expose-gc /** * This test verifies that the source map of a CJS module is cleared after the diff --git a/test/parallel/test-sqlite-session.js b/test/parallel/test-sqlite-session.js index e5a478e17061..1ced6e0c8b19 100644 --- a/test/parallel/test-sqlite-session.js +++ b/test/parallel/test-sqlite-session.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc --experimental-sqlite +// Flags: --allow-async-hooks --expose-gc --experimental-sqlite 'use strict'; const { skipIfSQLiteMissing } = require('../common'); skipIfSQLiteMissing(); diff --git a/test/parallel/test-stream-finished-bindAsyncResource-path.js b/test/parallel/test-stream-finished-bindAsyncResource-path.js index 82de2947c29b..4b7fa9a34053 100644 --- a/test/parallel/test-stream-finished-bindAsyncResource-path.js +++ b/test/parallel/test-stream-finished-bindAsyncResource-path.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-stream-writable-samecb-singletick.js b/test/parallel/test-stream-writable-samecb-singletick.js index 9357a56535b6..40a96436e2a7 100644 --- a/test/parallel/test-stream-writable-samecb-singletick.js +++ b/test/parallel/test-stream-writable-samecb-singletick.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Console } = require('console'); const { Writable } = require('stream'); diff --git a/test/parallel/test-tls-connect-memleak.js b/test/parallel/test-tls-connect-memleak.js index 220ea4a9248e..caaf647bec80 100644 --- a/test/parallel/test-tls-connect-memleak.js +++ b/test/parallel/test-tls-connect-memleak.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); if (!common.hasCrypto) diff --git a/test/parallel/test-util-debounce.js b/test/parallel/test-util-debounce.js index 15d93e610418..4a4a60af6319 100644 --- a/test/parallel/test-util-debounce.js +++ b/test/parallel/test-util-debounce.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-util-throttle.js b/test/parallel/test-util-throttle.js index b22fb4630e7e..9b3796598186 100644 --- a/test/parallel/test-util-throttle.js +++ b/test/parallel/test-util-throttle.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals +// Flags: --allow-async-hooks --expose-internals 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-v8-coverage.js b/test/parallel/test-v8-coverage.js index 0306e07c6fda..653db2142850 100644 --- a/test/parallel/test-v8-coverage.js +++ b/test/parallel/test-v8-coverage.js @@ -153,6 +153,7 @@ function nextdir() { { const coverageDirectory = tmpdir.resolve(nextdir()); const output = spawnSync(process.execPath, [ + '--allow-async-hooks', require.resolve('../fixtures/v8-coverage/async-hooks'), ], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } }); if (output.status !== 0) { diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js index dd51a879efff..a8e1443f737c 100644 --- a/test/parallel/test-v8-serialize-leak.js +++ b/test/parallel/test-v8-serialize-leak.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc const common = require('../common'); const { gcUntil } = require('../common/gc'); diff --git a/test/parallel/test-worker-hasref.js b/test/parallel/test-worker-hasref.js index 936a144bebba..148efa6b7626 100644 --- a/test/parallel/test-worker-hasref.js +++ b/test/parallel/test-worker-hasref.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-worker-message-port-inspect-during-init-hook.js b/test/parallel/test-worker-message-port-inspect-during-init-hook.js index d5784dceb71d..3f4e50b3d355 100644 --- a/test/parallel/test-worker-message-port-inspect-during-init-hook.js +++ b/test/parallel/test-worker-message-port-inspect-during-init-hook.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const util = require('util'); const assert = require('assert'); diff --git a/test/parallel/test-worker-messageport-hasref.js b/test/parallel/test-worker-messageport-hasref.js index c46feb7c66ee..bc6deeec66a6 100644 --- a/test/parallel/test-worker-messageport-hasref.js +++ b/test/parallel/test-worker-messageport-hasref.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --allow-async-hooks const common = require('../common'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-zlib-invalid-input-memory.js b/test/parallel/test-zlib-invalid-input-memory.js index ac718395dae1..28e1bd3e30ad 100644 --- a/test/parallel/test-zlib-invalid-input-memory.js +++ b/test/parallel/test-zlib-invalid-input-memory.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc 'use strict'; const common = require('../common'); const { onGC } = require('../common/gc'); diff --git a/test/pseudo-tty/test-async-wrap-getasyncid-tty.js b/test/pseudo-tty/test-async-wrap-getasyncid-tty.js index 5995a9118110..0a27ba338c17 100644 --- a/test/pseudo-tty/test-async-wrap-getasyncid-tty.js +++ b/test/pseudo-tty/test-async-wrap-getasyncid-tty.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals --no-warnings +// Flags: --allow-async-hooks --expose-internals --no-warnings 'use strict'; // See also test/sequential/test-async-wrap-getasyncid.js diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index 2cb15e144ee9..5c1ff4e7b7c3 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc --expose-internals --no-warnings --test-udp-no-try-send +// Flags: --allow-async-hooks --expose-gc --expose-internals --no-warnings --test-udp-no-try-send const common = require('../common'); const { internalBinding } = require('internal/test/binding'); diff --git a/test/sequential/test-gc-http-client-onerror.js b/test/sequential/test-gc-http-client-onerror.js index 1c311c6a9b64..0ab3930ed435 100644 --- a/test/sequential/test-gc-http-client-onerror.js +++ b/test/sequential/test-gc-http-client-onerror.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // just like test-gc-http-client.js, // but with an on('error') handler that does nothing. diff --git a/test/sequential/test-gc-http-client-timeout.js b/test/sequential/test-gc-http-client-timeout.js index bd5589fca109..fb7854f2481a 100644 --- a/test/sequential/test-gc-http-client-timeout.js +++ b/test/sequential/test-gc-http-client-timeout.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // Like test-gc-http-client.js, but with a timeout set. const common = require('../common'); diff --git a/test/sequential/test-gc-http-client.js b/test/sequential/test-gc-http-client.js index 6b2a5fc03afb..90f7e63e1250 100644 --- a/test/sequential/test-gc-http-client.js +++ b/test/sequential/test-gc-http-client.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-gc +// Flags: --allow-async-hooks --expose-gc // just a simple http server and client. const common = require('../common');