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>
22 lines
683 B
JavaScript
22 lines
683 B
JavaScript
// Flags: --expose-internals --no-async-context-frame
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Readable, finished } = require('stream');
|
|
const assert = require('assert');
|
|
const AsyncContextFrame = require('internal/async_context_frame');
|
|
const { enabledHooksExist } = require('internal/async_hooks');
|
|
|
|
// This test verifies that when there are no active async hooks, stream.finished() uses the default callback path
|
|
|
|
const readable = new Readable();
|
|
|
|
finished(readable, common.mustCall(() => {
|
|
assert.strictEqual(enabledHooksExist(), false);
|
|
assert.strictEqual(
|
|
AsyncContextFrame.current() || enabledHooksExist(),
|
|
false,
|
|
);
|
|
}));
|
|
|
|
readable.destroy();
|