PR-URL: https://github.com/nodejs/node/pull/57865 Reviewed-By: Raz Luvaton <rluvaton@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
21 lines
507 B
JavaScript
21 lines
507 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Readable, finished } = require('stream');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
const { strictEqual } = 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, () => {
|
|
finished(readable, common.mustCall(() => {
|
|
strictEqual(als.getStore(), 321);
|
|
}));
|
|
});
|
|
|
|
readable.destroy();
|