mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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. Signed-off-by: Divyanshu Sharma <Divyanshu88999@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63491 Fixes: https://github.com/nodejs/node/issues/63473 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
d3ef4122ee
commit
e4e5137cbd
1 file changed
+6
-1
+6
-1
@@ -1064,7 +1064,12 @@ void PerIsolateMessageListener(Local<Message> message, Local<Value> error) {
|
||||
filename,
|
||||
message->GetLineNumber(env->context()).FromMaybe(-1),
|
||||
msg);
|
||||
USE(ProcessEmitWarningGeneric(env, warning, "V8"));
|
||||
// Defer the warning to the next event loop iteration. This prevents
|
||||
// crashes when V8 emits warnings during code evaluation with
|
||||
// throwOnSideEffect.
|
||||
env->SetImmediate([warning](Environment* env) {
|
||||
ProcessEmitWarningGeneric(env, warning, "V8");
|
||||
});
|
||||
break;
|
||||
}
|
||||
case Isolate::MessageErrorLevel::kMessageError:
|
||||
|
||||
Reference in new issue
Block a user