2019-03-02 04:31:36 +08:00
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
|
2020-02-24 18:00:59 +08:00
|
|
|
asyncLocalStorage.run({}, (runArg) => {
|
2019-03-02 04:31:36 +08:00
|
|
|
assert.strictEqual(runArg, 'foo');
|
2020-03-14 14:06:06 +08:00
|
|
|
asyncLocalStorage.exit((exitArg) => {
|
2019-03-02 04:31:36 +08:00
|
|
|
assert.strictEqual(exitArg, 'bar');
|
|
|
|
}, 'bar');
|
|
|
|
}, 'foo');
|