mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
async_hooks: merge run and exit methods
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>
This commit is contained in:
parent
f7f0441997
commit
50dd63e8ef
12 changed files with 30 additions and 215 deletions
31
test/async-hooks/test-async-local-storage-errors.js
Normal file
31
test/async-hooks/test-async-local-storage-errors.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const { AsyncLocalStorage } = require('async_hooks');
|
||||
|
||||
// case 2 using *AndReturn calls (dual behaviors)
|
||||
const asyncLocalStorage = new AsyncLocalStorage();
|
||||
|
||||
let i = 0;
|
||||
process.setUncaughtExceptionCaptureCallback((err) => {
|
||||
++i;
|
||||
assert.strictEqual(err.message, 'err2');
|
||||
assert.strictEqual(asyncLocalStorage.getStore().get('hello'), 'node');
|
||||
});
|
||||
|
||||
try {
|
||||
asyncLocalStorage.run(new Map(), () => {
|
||||
const store = asyncLocalStorage.getStore();
|
||||
store.set('hello', 'node');
|
||||
setTimeout(() => {
|
||||
process.nextTick(() => {
|
||||
assert.strictEqual(i, 1);
|
||||
});
|
||||
throw new Error('err2');
|
||||
}, 0);
|
||||
throw new Error('err1');
|
||||
});
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.message, 'err1');
|
||||
assert.strictEqual(asyncLocalStorage.getStore(), undefined);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue