mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 00:20:38 +01:00
PR-URL: https://github.com/nodejs/node/pull/59873 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
22 lines
831 B
JavaScript
22 lines
831 B
JavaScript
// Flags: --expose-internals --no-async-context-frame
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Readable, finished } = require('stream');
|
|
const { strictEqual } = require('assert');
|
|
const AsyncContextFrame = require('internal/async_context_frame');
|
|
const internalAsyncHooks = 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(() => {
|
|
strictEqual(internalAsyncHooks.getHookArrays()[0].length === 0,
|
|
true, 'Should not have active user async hook');
|
|
strictEqual(AsyncContextFrame.current() || internalAsyncHooks.getHookArrays()[0].length > 0,
|
|
false, 'Default callback path should be used');
|
|
}));
|
|
|
|
readable.destroy();
|