mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
d1229eeca4
PR-URL: https://github.com/nodejs/node/pull/48528 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
29 lines
865 B
JavaScript
29 lines
865 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
const als = new AsyncLocalStorage();
|
|
|
|
// The _propagate function only exists on the old JavaScript implementation.
|
|
if (typeof als._propagate === 'function') {
|
|
// The als instance should be getting removed from the storageList in
|
|
// lib/async_hooks.js when exit(...) is called, therefore when the nested runs
|
|
// are called there should be no copy of the als in the storageList to run the
|
|
// _propagate method on.
|
|
als._propagate = common.mustNotCall('_propagate() should not be called');
|
|
}
|
|
|
|
const done = common.mustCall();
|
|
|
|
const data = true;
|
|
|
|
function run(count) {
|
|
if (count === 0) return done();
|
|
assert.notStrictEqual(als.getStore(), data);
|
|
als.run(data, () => {
|
|
als.exit(run, --count);
|
|
});
|
|
}
|
|
run(100);
|