Skip to content

Commit

Permalink
Revert "async_hooks: ensure proper handling in runInAsyncScope"
Browse files Browse the repository at this point in the history
This reverts commit a9fad85.
  • Loading branch information
MylesBorins committed Feb 14, 2020
1 parent 2ea5c91 commit e07237c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/async_hooks.js
Expand Up @@ -21,6 +21,7 @@ const {
executionAsyncId,
triggerAsyncId,
// Private API
hasAsyncIdStack,
getHookArrays,
enableHooks,
disableHooks,
Expand Down Expand Up @@ -171,13 +172,14 @@ class AsyncResource {
runInAsyncScope(fn, thisArg, ...args) {
const asyncId = this[async_id_symbol];
emitBefore(asyncId, this[trigger_async_id_symbol]);

const ret = thisArg === undefined ?
fn(...args) :
ReflectApply(fn, thisArg, args);

emitAfter(asyncId);
return ret;
try {
if (thisArg === undefined)
return fn(...args);
return ReflectApply(fn, thisArg, args);
} finally {
if (hasAsyncIdStack())
emitAfter(asyncId);
}
}

emitDestroy() {
Expand Down

0 comments on commit e07237c

Please sign in to comment.