fix: runtime JS error that crashes GetPackageJSON
(#48424)
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 <indutny@signal.org>
This commit is contained in:
parent
6dc3923b93
commit
f6238586d4
1 changed files with 4 additions and 3 deletions
|
@ -191,13 +191,15 @@ class Archive : public node::ObjectWrap {
|
||||||
static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
auto* isolate = args.GetIsolate();
|
auto* isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||||
|
args.GetReturnValue().Set(dict.GetHandle());
|
||||||
|
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (!gin::ConvertFromV8(isolate, args[0], &path)) {
|
if (!gin::ConvertFromV8(isolate, args[0], &path)) {
|
||||||
args.GetReturnValue().Set(v8::False(isolate));
|
dict.Set("isAsar", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
|
||||||
base::FilePath asar_path, file_path;
|
base::FilePath asar_path, file_path;
|
||||||
if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) {
|
if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) {
|
||||||
dict.Set("isAsar", true);
|
dict.Set("isAsar", true);
|
||||||
|
@ -206,7 +208,6 @@ static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
} else {
|
} else {
|
||||||
dict.Set("isAsar", false);
|
dict.Set("isAsar", false);
|
||||||
}
|
}
|
||||||
args.GetReturnValue().Set(dict.GetHandle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue