mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
50dd63e8ef
PR-URL: https://github.com/nodejs/node/pull/31950 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
20 lines
497 B
JavaScript
20 lines
497 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
async function test() {
|
|
asyncLocalStorage.getStore().set('foo', 'bar');
|
|
await Promise.resolve();
|
|
assert.strictEqual(asyncLocalStorage.getStore().get('foo'), 'bar');
|
|
}
|
|
|
|
async function main() {
|
|
await asyncLocalStorage.run(new Map(), test);
|
|
assert.strictEqual(asyncLocalStorage.getStore(), undefined);
|
|
}
|
|
|
|
main();
|