• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const assert = require('assert');
4const { AsyncLocalStorage } = require('async_hooks');
5
6const asyncLocalStorage = new AsyncLocalStorage();
7
8setImmediate(() => {
9  const store = { foo: 'bar' };
10  asyncLocalStorage.enterWith(store);
11
12  assert.strictEqual(asyncLocalStorage.getStore(), store);
13  setTimeout(() => {
14    assert.strictEqual(asyncLocalStorage.getStore(), store);
15  }, 10);
16});
17
18setTimeout(() => {
19  assert.strictEqual(asyncLocalStorage.getStore(), undefined);
20}, 10);
21