Bug 1549543 Make search initialization failures more obvious r=Gijs
authorAndrew Swan <aswan@mozilla.com>
Tue, 07 May 2019 13:46:17 +0000
changeset 531742 6ad2b2b28addd2d74dd85e21caac7e2cb631e776
parent 531741 4d5a0aca43c2f8303078cdc003848ce4930c6b10
child 531743 6064d6ac19ef551b9e656ca9ddd56b249473fb4e
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1549543
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549543 Make search initialization failures more obvious r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D30094
toolkit/components/search/SearchService.jsm
--- a/toolkit/components/search/SearchService.jsm
+++ b/toolkit/components/search/SearchService.jsm
@@ -722,40 +722,42 @@ SearchService.prototype = {
    *          Pass in `false` if the caller needs to be absolutely certain of the
    *          correct default engine and/ or ordering of visible engines.
    * @returns {Promise} A promise, resolved successfully if the initialization
    * succeeds.
    */
   async _init(skipRegionCheck) {
     LOG("_init start");
 
-    // See if we have a cache file so we don't have to parse a bunch of XML.
-    let cache = await this._readCacheFile();
-
-    // The init flow is not going to block on a fetch from an external service,
-    // but we're kicking it off as soon as possible to prevent UI flickering as
-    // much as possible.
-    this._ensureKnownRegionPromise = ensureKnownRegion(this)
-      .catch(ex => LOG("_init: failure determining region: " + ex))
-      .finally(() => this._ensureKnownRegionPromise = null);
-    if (!skipRegionCheck) {
-      await this._ensureKnownRegionPromise;
+    try {
+      // See if we have a cache file so we don't have to parse a bunch of XML.
+      let cache = await this._readCacheFile();
+
+      // The init flow is not going to block on a fetch from an external service,
+      // but we're kicking it off as soon as possible to prevent UI flickering as
+      // much as possible.
+      this._ensureKnownRegionPromise = ensureKnownRegion(this)
+        .catch(ex => LOG("_init: failure determining region: " + ex))
+        .finally(() => this._ensureKnownRegionPromise = null);
+      if (!skipRegionCheck) {
+        await this._ensureKnownRegionPromise;
+      }
+
+      this._setupRemoteSettings().catch(Cu.reportError);
+
+      await this._loadEngines(cache);
+
+      // Make sure the current list of engines is persisted, without the need to wait.
+      LOG("_init: engines loaded, writing cache");
+      this._buildCache();
+      this._addObservers();
+    } catch (ex) {
+      this._initRV = (ex.result !== undefined ? ex.result : Cr.NS_ERROR_FAILURE);
+      LOG("_init: failure initializng search: " + ex + "\n" + ex.stack);
     }
-
-    this._setupRemoteSettings().catch(Cu.reportError);
-
-    try {
-      await this._loadEngines(cache);
-    } catch (ex) {
-      this._initRV = Cr.NS_ERROR_FAILURE;
-      LOG("_init: failure loading engines: " + ex + "\n" + ex.stack);
-    }
-    // Make sure the current list of engines is persisted, without the need to wait.
-    this._buildCache();
-    this._addObservers();
     gInitialized = true;
     if (Components.isSuccessCode(this._initRV)) {
       this._initObservers.resolve(this._initRV);
     } else {
       this._initObservers.reject(this._initRV);
     }
     Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "init-complete");