node/test/async-hooks/test-async-local-storage-stream-finished.js
Antoine du Hamel bfc81ca228
test: ensure assertions are reachable in test/async-hooks
PR-URL: https://github.com/nodejs/node/pull/60150
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2025-10-09 21:57:24 +00:00

21 lines
522 B
JavaScript

'use strict';
const common = require('../common');
const { Readable, finished } = require('stream');
const { AsyncLocalStorage } = require('async_hooks');
const assert = require('assert');
// This test verifies that AsyncLocalStorage context is maintained
// when using stream.finished()
const readable = new Readable();
const als = new AsyncLocalStorage();
als.run(321, common.mustCall(() => {
finished(readable, common.mustCall(() => {
assert.strictEqual(als.getStore(), 321);
}));
}));
readable.destroy();