blob: 636d80f788b7fbb8708de6a4ba36898f5ebc627c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
'use strict';
const common = require('../common');
const assert = require('assert');
const { AsyncLocalStorage } = require('async_hooks');
const als = new AsyncLocalStorage();
// Make sure _propagate function exists.
assert.ok(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();
function run(count) {
if (count === 0) return done();
als.run({}, () => {
als.exit(run, --count);
});
}
run(100);
|