Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-11-18 18:37:07 +0300
committerAnna Henningsen <anna@addaleax.net>2017-11-21 15:57:05 +0300
commitc4a5de51e936940c9abce7761f2856ebf9202330 (patch)
tree6cd001b76ad6461da743f839c4bb18d6bd78eaa2 /lib/internal/inspector_async_hook.js
parent5d7f5c16b3ae49325b7bb0a79eaba3e945585ced (diff)
inspector: no async tracking for promises
`Promise` instances are already tracked by V8 itself. This fixes `sequential/test-inspector-async-stack-traces-promise-then` in debug mode (it previously crashed because our tracking and the V8 tracking were not properly nested). PR-URL: https://github.com/nodejs/node/pull/17118 Refs: https://chromium-review.googlesource.com/c/v8/v8/+/707058 Fixes: https://github.com/nodejs/node/issues/17017 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/inspector_async_hook.js')
-rw-r--r--lib/internal/inspector_async_hook.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/internal/inspector_async_hook.js b/lib/internal/inspector_async_hook.js
index 4ccf8626977..b190ff90b8e 100644
--- a/lib/internal/inspector_async_hook.js
+++ b/lib/internal/inspector_async_hook.js
@@ -16,22 +16,33 @@ const hook = createHook({
// in https://github.com/nodejs/node/pull/13870#discussion_r124515293,
// this should be fine as long as we call asyncTaskCanceled() too.
const recurring = true;
- inspector.asyncTaskScheduled(type, asyncId, recurring);
+ if (type === 'PROMISE')
+ this.promiseIds.add(asyncId);
+ else
+ inspector.asyncTaskScheduled(type, asyncId, recurring);
},
before(asyncId) {
+ if (this.promiseIds.has(asyncId))
+ return;
inspector.asyncTaskStarted(asyncId);
},
after(asyncId) {
+ if (this.promiseIds.has(asyncId))
+ return;
inspector.asyncTaskFinished(asyncId);
},
destroy(asyncId) {
+ if (this.promiseIds.has(asyncId))
+ return this.promiseIds.delete(asyncId);
inspector.asyncTaskCanceled(asyncId);
},
});
+hook.promiseIds = new Set();
+
function enable() {
if (config.bits < 64) {
// V8 Inspector stores task ids as (void*) pointers.