fix: net.isOnline always true in utility processes (#48153)

* fix: net.isOnline always true in utilityProcesses

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update shell/services/node/node_service.cc

Co-authored-by: Robo <hop2deep@gmail.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2025-08-22 13:22:30 -04:00
committed by GitHub
parent 550d390d24
commit 2a9780141c
2 changed files with 8 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "electron/mas.h"
#include "net/base/network_change_notifier.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
@@ -127,6 +128,10 @@ void NodeService::Initialize(
node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());
network_change_notifier_ = net::NetworkChangeNotifier::CreateIfNeeded(
net::NetworkChangeNotifier::CONNECTION_UNKNOWN,
net::NetworkChangeNotifier::ConnectionSubtype::SUBTYPE_UNKNOWN);
// Append program path for process.argv0
auto program = base::CommandLine::ForCurrentProcess()->GetProgram();
#if defined(OS_WIN)

View File

@@ -11,6 +11,7 @@
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/network_change_notifier.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom-forward.h"
@@ -84,6 +85,8 @@ class NodeService : public node::mojom::NodeService {
// depends-on: js_env_'s isolate
std::shared_ptr<node::Environment> node_env_;
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
};
} // namespace electron