Skip to content

Commit 99b20d4

Browse files
committed
errors: handle V8 warnings in DisallowJavascriptExecutionScope
Defer non-critical warnings to the next event loop iteration when can_call_into_js() returns false. This prevents crashes when V8 emits warnings during REPL preview evaluation or other contexts where JavaScript execution is temporarily forbidden. When a warning is emitted inside DisallowJavascriptExecutionScope, ProcessEmitWarningGeneric cannot be called immediately. Instead, use env->SetImmediate() to queue the warning emission for after the scope exits. This preserves full warning formatting, deprecation codes, and --redirect-warnings routing. Fixes: #63473 Signed-off-by: Divyanshu Sharma <Divyanshu88999@gmail.com>
1 parent 5ff701a commit 99b20d4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/node_errors.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,12 @@ void PerIsolateMessageListener(Local<Message> message, Local<Value> error) {
10641064
filename,
10651065
message->GetLineNumber(env->context()).FromMaybe(-1),
10661066
msg);
1067-
USE(ProcessEmitWarningGeneric(env, warning, "V8"));
1067+
// Defer the warning to the next event loop iteration. This prevents
1068+
// crashes when V8 emits warnings during code evaluation with
1069+
// throwOnSideEffect.
1070+
env->SetImmediate([warning](Environment* env) {
1071+
ProcessEmitWarningGeneric(env, warning, "V8");
1072+
});
10681073
break;
10691074
}
10701075
case Isolate::MessageErrorLevel::kMessageError:

0 commit comments

Comments
 (0)