Skip to content

Commit 9dc9c63

Browse files
devsnekV8 LUCI CQ
authored andcommitted
fix thenable async stack trace
Bug: 332083029 Change-Id: Ia8fc66b18d64f014b5f5546a171abb8821d8c645 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6826001 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: snek <[email protected]> Cr-Commit-Position: refs/heads/main@{#101788}
1 parent 8339ba5 commit 9dc9c63

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/execution/isolate.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,12 @@ MaybeDirectHandle<JSPromise> TryGetCurrentTaskPromise(Isolate* isolate) {
13281328
return promise;
13291329
}
13301330
}
1331+
} else if (IsPromiseResolveThenableJobTask(*current_microtask)) {
1332+
auto promise_resolve_thenable_job_task =
1333+
Cast<PromiseResolveThenableJobTask>(current_microtask);
1334+
DirectHandle<JSPromise> promise(
1335+
promise_resolve_thenable_job_task->promise_to_resolve(), isolate);
1336+
return promise;
13311337
}
13321338
return MaybeDirectHandle<JSPromise>();
13331339
}

test/mjsunit/async-stack-traces.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,36 @@
354354
await test(one);
355355
})());
356356
})();
357+
358+
// test thenable job
359+
(function() {
360+
async function one(x) {
361+
await two(x);
362+
}
363+
364+
async function two(x) {
365+
await x;
366+
await { then() { throw new Error() } };
367+
}
368+
369+
async function test(f) {
370+
try {
371+
await f(1);
372+
assertUnreachable();
373+
} catch (e) {
374+
assertInstanceof(e, Error);
375+
assertMatches(/Error.+at Object\.then.+at async two.+at async one.+at async test/ms, e.stack);
376+
}
377+
}
378+
379+
assertPromiseResult((async () => {
380+
%PrepareFunctionForOptimization(one);
381+
%PrepareFunctionForOptimization(two);
382+
await test(one);
383+
await test(one);
384+
%OptimizeFunctionOnNextCall(two);
385+
await test(one);
386+
%OptimizeFunctionOnNextCall(one);
387+
await test(one);
388+
})());
389+
})();

0 commit comments

Comments
 (0)