Skip to content

Commit e7d45d6

Browse files
committed
added check if no-async-context-frame is enabled or not
1 parent be63774 commit e7d45d6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/streams/end-of-stream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const {
4444
kIsClosedPromise,
4545
} = require('internal/streams/utils');
4646

47+
const { getHookArrays } = require('internal/async_hooks');
4748
const AsyncContextFrame = require('internal/async_context_frame');
4849

4950
// Lazy load
@@ -68,7 +69,8 @@ function eos(stream, options, callback) {
6869
validateFunction(callback, 'callback');
6970
validateAbortSignal(options.signal, 'options.signal');
7071

71-
if (AsyncContextFrame.current()) {
72+
if ((AsyncContextFrame.enabled && AsyncContextFrame.current()) ||
73+
(!AsyncContextFrame.enabled && getHookArrays()[0].length > 0)) {
7274
AsyncLocalStorage ??= require('async_hooks').AsyncLocalStorage;
7375
callback = once(AsyncLocalStorage.bind(callback));
7476
} else {

0 commit comments

Comments
 (0)