Files
node/test/parallel/test-async-hooks-enabledhooksexits.js
Gerhard Stöbich 926162a2ea async_hooks: enabledHooksExist shall return if hooks are enabled
Correct the implementaton of enabledHooksExist to return true if
there are enabled hooks.

Adapt callsites which used getHooksArrays() as workaround.

PR-URL: https://github.com/nodejs/node/pull/61054
Fixes: https://github.com/nodejs/node/issues/61019
Refs: https://github.com/nodejs/node/pull/59873
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2025-12-31 14:45:20 +00:00

19 lines
459 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const { createHook } = require('async_hooks');
const { enabledHooksExist } = require('internal/async_hooks');
assert.strictEqual(enabledHooksExist(), false);
const ah = createHook({});
assert.strictEqual(enabledHooksExist(), false);
ah.enable();
assert.strictEqual(enabledHooksExist(), true);
ah.disable();
assert.strictEqual(enabledHooksExist(), false);