Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94e0488

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
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: #17118 Refs: https://chromium-review.googlesource.com/c/v8/v8/+/707058 Fixes: #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>
1 parent 5247ab3 commit 94e0488
Copy full SHA for 94e0488

File tree

Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/inspector_async_hook.js‎

Copy file name to clipboardExpand all lines: lib/internal/inspector_async_hook.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,33 @@ const hook = createHook({
1616
// in https://github.com/nodejs/node/pull/13870#discussion_r124515293,
1717
// this should be fine as long as we call asyncTaskCanceled() too.
1818
const recurring = true;
19-
inspector.asyncTaskScheduled(type, asyncId, recurring);
19+
if (type === 'PROMISE')
20+
this.promiseIds.add(asyncId);
21+
else
22+
inspector.asyncTaskScheduled(type, asyncId, recurring);
2023
},
2124

2225
before(asyncId) {
26+
if (this.promiseIds.has(asyncId))
27+
return;
2328
inspector.asyncTaskStarted(asyncId);
2429
},
2530

2631
after(asyncId) {
32+
if (this.promiseIds.has(asyncId))
33+
return;
2734
inspector.asyncTaskFinished(asyncId);
2835
},
2936

3037
destroy(asyncId) {
38+
if (this.promiseIds.has(asyncId))
39+
return this.promiseIds.delete(asyncId);
3140
inspector.asyncTaskCanceled(asyncId);
3241
},
3342
});
3443

44+
hook.promiseIds = new Set();
45+
3546
function enable() {
3647
if (config.bits < 64) {
3748
// V8 Inspector stores task ids as (void*) pointers.
Collapse file

‎test/sequential/test-inspector-async-stack-traces-promise-then.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-inspector-async-stack-traces-promise-then.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function debuggerPausedAt(msg, functionName, previousTickLocation) {
5454
`${Object.keys(msg.params)} contains "asyncStackTrace" property`);
5555

5656
assert.strictEqual(msg.params.callFrames[0].functionName, functionName);
57-
assert.strictEqual(msg.params.asyncStackTrace.description, 'PROMISE');
57+
assert.strictEqual(msg.params.asyncStackTrace.description, 'Promise.resolve');
5858

5959
const frameLocations = msg.params.asyncStackTrace.callFrames.map(
6060
(frame) => `${frame.functionName}:${frame.lineNumber}`);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.