mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
async_hooks: ensure event after been emitted on runInAsyncScope
The exception handler user-defined will not automatically emit after for the async resource. Also removes a duplicated case `test-emit-after-uncaught-exception-runInAsyncScope.js` which is identical to test-emit-after-uncaught-exception.js. Refs: https://github.com/nodejs/node/pull/30965 PR-URL: https://github.com/nodejs/node/pull/31784 Fixes: https://github.com/nodejs/node/issues/31783 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
df1592d2e9
commit
75311dbc2f
3 changed files with 19 additions and 45 deletions
|
@ -22,6 +22,7 @@ const {
|
|||
executionAsyncId,
|
||||
triggerAsyncId,
|
||||
// Private API
|
||||
hasAsyncIdStack,
|
||||
getHookArrays,
|
||||
enableHooks,
|
||||
disableHooks,
|
||||
|
@ -179,12 +180,16 @@ class AsyncResource {
|
|||
const asyncId = this[async_id_symbol];
|
||||
emitBefore(asyncId, this[trigger_async_id_symbol], this);
|
||||
|
||||
const ret = thisArg === undefined ?
|
||||
fn(...args) :
|
||||
ReflectApply(fn, thisArg, args);
|
||||
try {
|
||||
const ret = thisArg === undefined ?
|
||||
fn(...args) :
|
||||
ReflectApply(fn, thisArg, args);
|
||||
|
||||
emitAfter(asyncId);
|
||||
return ret;
|
||||
return ret;
|
||||
} finally {
|
||||
if (hasAsyncIdStack())
|
||||
emitAfter(asyncId);
|
||||
}
|
||||
}
|
||||
|
||||
emitDestroy() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue