mirror of
https://github.com/nodejs/node.git
synced 2026-10-29 02:35:20 +08:00
Remove the async_hooks-based AsyncLocalStorage fallback and the --no-async-context-frame flag, making AsyncContextFrame the sole implementation. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63641 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
37 lines
998 B
JavaScript
37 lines
998 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const {
|
|
AsyncLocalStorage,
|
|
} = require('async_hooks');
|
|
|
|
const assert = require('assert');
|
|
|
|
// ============================================================================
|
|
// The defaultValue option
|
|
const als1 = new AsyncLocalStorage();
|
|
assert.strictEqual(als1.getStore(), undefined);
|
|
|
|
const als2 = new AsyncLocalStorage({ defaultValue: 'default' });
|
|
assert.strictEqual(als2.getStore(), 'default');
|
|
|
|
const als3 = new AsyncLocalStorage({ defaultValue: 42 });
|
|
assert.strictEqual(als3.getStore(), 42);
|
|
|
|
const als4 = new AsyncLocalStorage({ defaultValue: null });
|
|
assert.strictEqual(als4.getStore(), null);
|
|
|
|
assert.throws(() => new AsyncLocalStorage(null), {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
});
|
|
|
|
// ============================================================================
|
|
// The name option
|
|
|
|
const als5 = new AsyncLocalStorage({ name: 'test' });
|
|
assert.strictEqual(als5.name, 'test');
|
|
|
|
const als6 = new AsyncLocalStorage();
|
|
assert.strictEqual(als6.name, '');
|