Skip to content

Commit

Permalink
backport microtasks fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed Sep 16, 2019
1 parent a43bbbc commit 8301091
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/node/.patches
Expand Up @@ -39,3 +39,4 @@ chore_split_createenvironment_into_createenvironment_and.patch
chore_handle_default_configuration_not_being_set_in_the_electron_env.patch
revert_crypto_add_outputlength_option_to_crypto_createhash.patch
add_openssl_is_boringssl_guard_to_oaep_hash_check.patch
fix_microtasks.patch
58 changes: 58 additions & 0 deletions patches/node/fix_microtasks.patch
@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Mon, 16 Sep 2019 17:50:28 -0400
Subject: fix microtasks

backports https://github.com/nodejs/node/pull/29581 and https://github.com/nodejs/node/pull/29434

diff --git a/src/api/callback.cc b/src/api/callback.cc
index 43ccfafd9f2c85e23a9ea6277e88e4864e287905..3c518870c9c8d92f3dfcd6c270f5e023e3b69633 100644
--- a/src/api/callback.cc
+++ b/src/api/callback.cc
@@ -12,6 +12,7 @@ using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::MaybeLocal;
+using v8::MicrotasksScope;
using v8::NewStringType;
using v8::Object;
using v8::String;
@@ -100,7 +101,7 @@ void InternalCallbackScope::Close() {

if (!env_->can_call_into_js()) return;
if (!tick_info->has_tick_scheduled()) {
- env_->isolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(env_->isolate());
}

#if 0 // FIXME(codebytere): figure out why this check fails/causes crash
diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc
index e6b4d0b8e211cdb1fef4759457c2550e28448360..918796ba77d80cf66324164a930f8068e0622ccb 100644
--- a/src/node_task_queue.cc
+++ b/src/node_task_queue.cc
@@ -21,6 +21,7 @@ using v8::kPromiseRejectWithNoHandler;
using v8::kPromiseResolveAfterResolved;
using v8::Local;
using v8::Message;
+using v8::MicrotasksScope;
using v8::Number;
using v8::Object;
using v8::Promise;
@@ -43,7 +44,7 @@ static void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
bool RunNextTicksNative(Environment* env) {
TickInfo* tick_info = env->tick_info();
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
- env->isolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(env->isolate());
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
return true;

@@ -54,7 +55,7 @@ bool RunNextTicksNative(Environment* env) {
}

static void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
- args.GetIsolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(args.GetIsolate());
}

static void SetTickCallback(const FunctionCallbackInfo<Value>& args) {

0 comments on commit 8301091

Please sign in to comment.