Skip to content

Commit ca76392

Browse files
bmeurerCommit Bot
authored and
Commit Bot
committed
[promises] Correctly run before/after hooks for await.
This fixes a bug where we didn't run before/after hooks for await when the debugger is not active, as reported downstream in nodejs/node#20274 Change-Id: I1948d1884c591418d87ffd1d0ccb2bebf4e908f1 Reviewed-on: https://chromium-review.googlesource.com/1039386 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#52909}
1 parent a9db2c7 commit ca76392

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/builtins/builtins-async-gen.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void AsyncBuiltinsAssembler::Await(Node* context, Node* generator, Node* value,
4444
// When debugging, we need to link from the {generator} to the
4545
// {outer_promise} of the async function/generator.
4646
Label done(this);
47-
GotoIfNot(IsDebugActive(), &done);
47+
GotoIfNot(IsPromiseHookEnabledOrDebugIsActive(), &done);
4848
CallRuntime(Runtime::kSetProperty, native_context, generator,
4949
LoadRoot(Heap::kgenerator_outer_promise_symbolRootIndex),
5050
outer_promise, SmiConstant(LanguageMode::kStrict));

test/cctest/test-api.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18309,6 +18309,12 @@ TEST(PromiseHook) {
1830918309
CHECK_EQ(v8::Promise::kFulfilled, GetPromise("p")->State());
1831018310
CHECK_EQ(9, promise_hook_data->promise_hook_count);
1831118311

18312+
promise_hook_data->Reset();
18313+
source = "(async() => await p)();\n";
18314+
18315+
CompileRun(source);
18316+
CHECK_EQ(11, promise_hook_data->promise_hook_count);
18317+
1831218318
delete promise_hook_data;
1831318319
isolate->SetPromiseHook(nullptr);
1831418320
}

0 commit comments

Comments
 (0)