Repository: electron/electron
File: shell/services/node/node_service.cc (C++)

Code before:
  return host_resolver_.get();
}

bool URLLoaderBundle::ShouldUseNetworkObserverfromURLLoaderFactory() const {
  return should_use_network_observer_from_url_loader_factory_;
}

NodeService::NodeService(
    mojo::PendingReceiver<node::mojom::NodeService> receiver)
    : node_bindings_{NodeBindings::Create(
          NodeBindings::BrowserEnvironment::kUtility)},
      electron_bindings_{
          std::make_unique<ElectronBindings>(node_bindings_->uv_loop())} {
  if (receiver.is_valid())
    receiver_.Bind(std::move(receiver));
}

NodeService::~NodeService() {
  if (!node_env_stopped_) {
    node_env_->set_trace_sync_io(false);
    ParentPort::GetInstance()->Close();
    js_env_->DestroyMicrotasksRunner();
    node::Stop(node_env_.get(), node::StopFlags::kDoNotTerminateIsolate);
    if (g_client_remote.is_bound()) {
      g_client_remote.reset();
    }
  }
}

void NodeService::Initialize(
    node::mojom::NodeServiceParamsPtr params,
    mojo::PendingRemote<node::mojom::NodeServiceClient> client_pending_remote) {
  if (NodeBindings::IsInitialized())
    return;

  g_client_remote.Bind(std::move(client_pending_remote));
  g_client_remote.reset_on_disconnect();

  ParentPort::GetInstance()->Initialize(std::move(params->port));

  URLLoaderBundle::GetInstance()->SetURLLoaderFactory(
      std::move(params->url_loader_factory),
      mojo::Remote(std::move(params->host_resolver)),
      params->use_network_observer_from_url_loader_factory);

  js_env_ = std::make_unique<JavascriptEnvironment>(node_bindings_->uv_loop());

  v8::HandleScope scope(js_env_->isolate());

  node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());


Review comment (suggestion):
```suggestion
    g_client_remote.reset();
```

Same here

Code after:
  return host_resolver_.get();
}

bool URLLoaderBundle::ShouldUseNetworkObserverfromURLLoaderFactory() const {
  return should_use_network_observer_from_url_loader_factory_;
}

NodeService::NodeService(
    mojo::PendingReceiver<node::mojom::NodeService> receiver)
    : node_bindings_{NodeBindings::Create(
          NodeBindings::BrowserEnvironment::kUtility)},
      electron_bindings_{
          std::make_unique<ElectronBindings>(node_bindings_->uv_loop())} {
  if (receiver.is_valid())
    receiver_.Bind(std::move(receiver));
}

NodeService::~NodeService() {
  if (!node_env_stopped_) {
    node_env_->set_trace_sync_io(false);
    ParentPort::GetInstance()->Close();
    js_env_->DestroyMicrotasksRunner();
    node::Stop(node_env_.get(), node::StopFlags::kDoNotTerminateIsolate);
    g_client_remote.reset();
  }
}

void NodeService::Initialize(
    node::mojom::NodeServiceParamsPtr params,
    mojo::PendingRemote<node::mojom::NodeServiceClient> client_pending_remote) {
  if (NodeBindings::IsInitialized())
    return;

  g_client_remote.Bind(std::move(client_pending_remote));
  g_client_remote.reset_on_disconnect();

  ParentPort::GetInstance()->Initialize(std::move(params->port));

  URLLoaderBundle::GetInstance()->SetURLLoaderFactory(
      std::move(params->url_loader_factory),
      mojo::Remote(std::move(params->host_resolver)),
      params->use_network_observer_from_url_loader_factory);

  js_env_ = std::make_unique<JavascriptEnvironment>(node_bindings_->uv_loop());

  v8::HandleScope scope(js_env_->isolate());

  node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());

  // Append program path for process.argv0
  auto program = base::CommandLine::ForCurrentProcess()->GetProgram();