From ba71fe8bd306a562d4888e5737caeca975a12a07 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Thu, 31 May 2018 12:10:07 +0200 Subject: [PATCH] timers: check can_call_into_js in Immediates Prevent an infinite loop if it's not possible to call into JS. PR-URL: https://github.com/nodejs/node/pull/21057 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- src/env.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/env.cc b/src/env.cc index 32ffd402da049a..7865ba95404df5 100644 --- a/src/env.cc +++ b/src/env.cc @@ -457,6 +457,9 @@ void Environment::CheckImmediate(uv_check_t* handle) { env->RunAndClearNativeImmediates(); + if (!env->can_call_into_js()) + return; + do { MakeCallback(env->isolate(), env->process_object(), @@ -464,7 +467,7 @@ void Environment::CheckImmediate(uv_check_t* handle) { 0, nullptr, {0, 0}).ToLocalChecked(); - } while (env->immediate_info()->has_outstanding()); + } while (env->immediate_info()->has_outstanding() && env->can_call_into_js()); if (env->immediate_info()->ref_count() == 0) env->ToggleImmediateRef(false);