chore: better logging if Node initialization fails (#45317)

feat: better logging if Node initialization fails

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-01-23 12:16:18 -06:00 committed by GitHub
parent 91bb748eaa
commit 724744af16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 74 additions and 21 deletions

View file

@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_COMMON_NODE_UTIL_H_
#define ELECTRON_SHELL_COMMON_NODE_UTIL_H_
#include <string>
#include <string_view>
#include <vector>
@ -13,7 +14,13 @@
namespace node {
class Environment;
class IsolateData;
struct ThreadId;
namespace EnvironmentFlags {
enum Flags : uint64_t;
}
} // namespace node
namespace electron::util {
@ -37,6 +44,15 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
std::vector<v8::Local<v8::String>>* parameters,
std::vector<v8::Local<v8::Value>>* arguments);
// Wrapper for node::CreateEnvironment that logs failure
node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::IsolateData* isolate_data,
v8::Local<v8::Context> context,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args,
node::EnvironmentFlags::Flags env_flags,
std::string_view process_type = "");
// Convenience function to view a Node buffer's data as a base::span().
// Analogous to base::as_byte_span()
[[nodiscard]] base::span<uint8_t> as_byte_span(