mirror of
https://github.com/nodejs/node.git
synced 2026-12-05 12:48:45 -05:00
PR-URL: https://github.com/nodejs/node/pull/60760 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
23 lines
739 B
JavaScript
23 lines
739 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 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(() => {
|
|
assert.strictEqual(internalAsyncHooks.getHookArrays()[0].length === 0, true);
|
|
assert.strictEqual(
|
|
AsyncContextFrame.current() || internalAsyncHooks.getHookArrays()[0].length > 0,
|
|
false,
|
|
);
|
|
}));
|
|
|
|
readable.destroy();
|