mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/60150 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
21 lines
581 B
JavaScript
21 lines
581 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
setImmediate(common.mustCall(() => {
|
|
const store = { foo: 'bar' };
|
|
asyncLocalStorage.enterWith(store);
|
|
|
|
assert.strictEqual(asyncLocalStorage.getStore(), store);
|
|
setTimeout(common.mustCall(() => {
|
|
assert.strictEqual(asyncLocalStorage.getStore(), store);
|
|
}), 10);
|
|
}));
|
|
|
|
setTimeout(common.mustCall(() => {
|
|
assert.strictEqual(asyncLocalStorage.getStore(), undefined);
|
|
}), 10);
|