1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const { AsyncLocalStorage } = require('async_hooks');
5
6const als = new AsyncLocalStorage();
7
8// Make sure _propagate function exists.
9assert.ok(typeof als._propagate === 'function');
10
11// The als instance should be getting removed from the storageList in
12// lib/async_hooks.js when exit(...) is called, therefore when the nested runs
13// are called there should be no copy of the als in the storageList to run the
14// _propagate method on.
15als._propagate = common.mustNotCall('_propagate() should not be called');
16
17const done = common.mustCall();
18
19function run(count) {
20  if (count === 0) return done();
21  als.run({}, () => {
22    als.exit(run, --count);
23  });
24}
25run(100);
26