From 3a9ca3234e715406a8e4a66c4080fe0969b8d3e8 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 21:00:06 -0500 Subject: [PATCH] fix: runtime JS error that crashes `GetPackageJSON` (#48423) We overriden the `GetPackageJSON` in Node.js to let us read files straight from the ASAR file instead of disk. The override works by providing a JS method with the limitation that it should not throw a runtime error. However, this invariant was accidentally violated by `asar.splitPath` that sometimes contrary to its' TypeScript definition returned `false`. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Fedor Indutny --- shell/common/api/electron_api_asar.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/common/api/electron_api_asar.cc b/shell/common/api/electron_api_asar.cc index 810f3ffdb6d..c9d36958e00 100644 --- a/shell/common/api/electron_api_asar.cc +++ b/shell/common/api/electron_api_asar.cc @@ -191,13 +191,15 @@ class Archive : public node::ObjectWrap { static void SplitPath(const v8::FunctionCallbackInfo& args) { auto* isolate = args.GetIsolate(); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); + args.GetReturnValue().Set(dict.GetHandle()); + base::FilePath path; if (!gin::ConvertFromV8(isolate, args[0], &path)) { - args.GetReturnValue().Set(v8::False(isolate)); + dict.Set("isAsar", false); return; } - auto dict = gin_helper::Dictionary::CreateEmpty(isolate); base::FilePath asar_path, file_path; if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) { dict.Set("isAsar", true); @@ -206,7 +208,6 @@ static void SplitPath(const v8::FunctionCallbackInfo& args) { } else { dict.Set("isAsar", false); } - args.GetReturnValue().Set(dict.GetHandle()); } void Initialize(v8::Local exports,