diff --git a/src/node_errors.cc b/src/node_errors.cc index 74326496132773..387a71eccd32a3 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -1064,7 +1064,14 @@ void PerIsolateMessageListener(Local message, Local error) { filename, message->GetLineNumber(env->context()).FromMaybe(-1), msg); - USE(ProcessEmitWarningGeneric(env, warning, "V8")); + if (!env->can_call_into_js()) { + std::string warning_str = warning; + env->SetImmediate([warning_str](Environment* env) { + USE(ProcessEmitWarningGeneric(env, warning_str, "V8")); + }); + } else { + USE(ProcessEmitWarningGeneric(env, warning, "V8")); + } break; } case Isolate::MessageErrorLevel::kMessageError: diff --git a/test/parallel/test-repl-asm-warning.js b/test/parallel/test-repl-asm-warning.js new file mode 100644 index 00000000000000..c21672a1f0839e --- /dev/null +++ b/test/parallel/test-repl-asm-warning.js @@ -0,0 +1,30 @@ +'use strict'; +const common = require('../common'); +const { startNewREPLServer } = require('../common/repl'); + +common.skipIfInspectorDisabled(); + +// Regression test for https://github.com/nodejs/node/issues/63473 +// V8 warnings emitted during REPL inspector preview inside +// DisallowJavascriptExecutionScope should not crash the process. + +const { replServer, input } = startNewREPLServer({ + terminal: true, + preview: true, +}); + +try { + input.run([ + 'function AsmModule() {', + " 'use asm';", + ' function add(a, b) {', + ' a = a | 0;', + ' b = b | 0;', + ' return a + b;', + ' }', + '}', + 'AsmModule();', + ]); +} finally { + replServer.close(); +}