summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-10-23 16:06:16 +0200
committerAnna Henningsen <anna@addaleax.net>2019-10-26 15:19:23 +0200
commit6858c7e3e7c30986d68a683d3d5e4ede4c0b529f (patch)
tree515636c8d386a4f1bd66f3b4ef6988499c9c5540 /lib
parentcb36fa67d77ff6891a48db0b473d1c51888e23ed (diff)
downloadandroid-node-v8-6858c7e3e7c30986d68a683d3d5e4ede4c0b529f.tar.gz
android-node-v8-6858c7e3e7c30986d68a683d3d5e4ede4c0b529f.tar.bz2
android-node-v8-6858c7e3e7c30986d68a683d3d5e4ede4c0b529f.zip
async_hooks: only emit `after` for AsyncResource if stack not empty
We clear the async id stack inside the uncaught exception handler and emit `after` events in the process, so we should not emit `after` a second time from the `runInAsyncScope()` code. This should match the behaviour we have in C++. Fixes: https://github.com/nodejs/node/issues/30080 PR-URL: https://github.com/nodejs/node/pull/30087 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/async_hooks.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/async_hooks.js b/lib/async_hooks.js
index 0c17705536..c18a902c2a 100644
--- a/lib/async_hooks.js
+++ b/lib/async_hooks.js
@@ -17,6 +17,7 @@ const {
executionAsyncId,
triggerAsyncId,
// Private API
+ hasAsyncIdStack,
getHookArrays,
enableHooks,
disableHooks,
@@ -172,7 +173,8 @@ class AsyncResource {
return fn(...args);
return Reflect.apply(fn, thisArg, args);
} finally {
- emitAfter(asyncId);
+ if (hasAsyncIdStack())
+ emitAfter(asyncId);
}
}