Skip to content

Commit 5c3d484

Browse files
codebyteretargos
authored andcommitted
src: check microtasks before running them
PR-URL: #29434 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent d2b0568 commit 5c3d484

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/api/callback.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using v8::HandleScope;
1212
using v8::Isolate;
1313
using v8::Local;
1414
using v8::MaybeLocal;
15+
using v8::MicrotasksScope;
1516
using v8::NewStringType;
1617
using v8::Object;
1718
using v8::String;
@@ -100,7 +101,7 @@ void InternalCallbackScope::Close() {
100101

101102
if (!env_->can_call_into_js()) return;
102103
if (!tick_info->has_tick_scheduled()) {
103-
env_->isolate()->RunMicrotasks();
104+
MicrotasksScope::PerformCheckpoint(env_->isolate());
104105
}
105106

106107
// Make sure the stack unwound properly. If there are nested MakeCallback's

src/node_task_queue.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ using v8::kPromiseRejectWithNoHandler;
2121
using v8::kPromiseResolveAfterResolved;
2222
using v8::Local;
2323
using v8::Message;
24+
using v8::MicrotasksScope;
2425
using v8::Number;
2526
using v8::Object;
2627
using v8::Promise;
@@ -43,7 +44,7 @@ static void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
4344
bool RunNextTicksNative(Environment* env) {
4445
TickInfo* tick_info = env->tick_info();
4546
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
46-
env->isolate()->RunMicrotasks();
47+
MicrotasksScope::PerformCheckpoint(env->isolate());
4748
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
4849
return true;
4950

0 commit comments

Comments
 (0)