mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
9a82938b82
PR-URL: https://github.com/nodejs/node/pull/46387 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
17 lines
495 B
JavaScript
17 lines
495 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { strictEqual } = require('assert');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
const runInAsyncScope =
|
|
asyncLocalStorage.run(123, common.mustCall(() => AsyncLocalStorage.snapshot()));
|
|
const result =
|
|
asyncLocalStorage.run(321, common.mustCall(() => {
|
|
return runInAsyncScope(() => {
|
|
return asyncLocalStorage.getStore();
|
|
});
|
|
}));
|
|
strictEqual(result, 123);
|