From aa8119515f87d87716345cf454da5113e700ab69 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Mon, 7 Mar 2022 16:52:40 -0800 Subject: [PATCH] fix: gracefully fail if app.configureHostResolver is called before ready (#33062) --- shell/browser/api/electron_api_app.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index d2de05d363f..bcc96086557 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -1630,6 +1630,11 @@ v8::Local App::GetDockAPI(v8::Isolate* isolate) { void ConfigureHostResolver(v8::Isolate* isolate, const gin_helper::Dictionary& opts) { gin_helper::ErrorThrower thrower(isolate); + if (!Browser::Get()->is_ready()) { + thrower.ThrowError( + "configureHostResolver cannot be called before the app is ready"); + return; + } net::SecureDnsMode secure_dns_mode = net::SecureDnsMode::kOff; std::string default_doh_templates; if (base::FeatureList::IsEnabled(features::kDnsOverHttps)) {