Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94357db

Browse filesBrowse files
committed
src: add more can_call_into_js() guards
This is in preparation for running native `SetImmediate()` callbacks during shutdown. PR-URL: #30666 Fixes: #30643 Refs: #30374 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d54432f commit 94357db
Copy full SHA for 94357db

File tree

Expand file treeCollapse file tree

3 files changed

+10
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-2
lines changed
Open diff view settings
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ void Environment::RegisterHandleCleanups() {
540540
}
541541

542542
void Environment::CleanupHandles() {
543+
Isolate::DisallowJavascriptExecutionScope disallow_js(isolate(),
544+
Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
545+
543546
for (ReqWrapBase* request : req_wrap_queue_)
544547
request->Cancel();
545548

@@ -674,7 +677,7 @@ void Environment::RunAndClearNativeImmediates() {
674677

675678
head->Call(this);
676679
if (UNLIKELY(try_catch.HasCaught())) {
677-
if (!try_catch.HasTerminated())
680+
if (!try_catch.HasTerminated() && can_call_into_js())
678681
errors::TriggerUncaughtException(isolate(), try_catch);
679682

680683
// We are done with the current callback. Move one iteration along,
Collapse file

‎src/node_errors.cc‎

Copy file name to clipboardExpand all lines: src/node_errors.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ static void ReportFatalException(Environment* env,
278278
Local<Value> error,
279279
Local<Message> message,
280280
EnhanceFatalException enhance_stack) {
281+
if (!env->can_call_into_js())
282+
enhance_stack = EnhanceFatalException::kDontEnhance;
283+
281284
Isolate* isolate = env->isolate();
282285
CHECK(!error.IsEmpty());
283286
CHECK(!message.IsEmpty());
@@ -956,7 +959,7 @@ void TriggerUncaughtException(Isolate* isolate,
956959
}
957960

958961
MaybeLocal<Value> handled;
959-
{
962+
if (env->can_call_into_js()) {
960963
// We do not expect the global uncaught exception itself to throw any more
961964
// exceptions. If it does, exit the current Node.js instance.
962965
errors::TryCatchScope try_catch(env,
Collapse file

‎src/node_process_events.cc‎

Copy file name to clipboardExpand all lines: src/node_process_events.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
3434
const char* warning,
3535
const char* type,
3636
const char* code) {
37+
if (!env->can_call_into_js()) return Just(false);
38+
3739
HandleScope handle_scope(env->isolate());
3840
Context::Scope context_scope(env->context());
3941

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.