From 2dcb2b08c8b0dfc824968168ffccc0438a8422a2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 2 Nov 2024 19:46:32 -0700 Subject: [PATCH] Ignore non-integers in process.reallyExit() --- src/bun.js/bindings/BunProcess.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index ce076e0fe5..f3e8787cff 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -2212,6 +2212,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, (JSGlobalObject * jsGlobalObje return {}; } +// https://github.com/nodejs/node/blob/2eff28fb7a93d3f672f80b582f664a7c701569fb/src/node_process_methods.cc#L465-L470 JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObject, CallFrame* callFrame)) { auto& vm = globalObject->vm(); @@ -2221,10 +2222,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj if (arg0.isAnyInt()) { exitCode = static_cast(arg0.toInt32(globalObject) % 256); RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - } else if (!arg0.isUndefinedOrNull()) { - throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); - return {}; } else { + // ignore non-integers, matching Node.js behavior. exitCode = Bun__getExitCode(bunVM(globalObject)); }