Bug 1038068: Always log errors from saving the extensions database. r=dveditz
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 23 Apr 2015 14:43:37 -0700
changeset 240910 ebc84b792237ffe7ee2fb9640e8f3b6e37364783
parent 240909 137707995d3ad1b357e2f7795ac2b30e60b77a06
child 240911 1cfe7aee45084049b9dc9c55c424f0665d27f154
push id12569
push userdtownsend@mozilla.com
push dateFri, 24 Apr 2015 18:16:48 +0000
treeherderfx-team@1cfe7aee4508 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz
bugs1038068
milestone40.0a1
Bug 1038068: Always log errors from saving the extensions database. r=dveditz
toolkit/mozapps/extensions/internal/XPIProviderUtils.js
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
@@ -434,34 +434,39 @@ this.XPIDatabase = {
       this._deferredSave = new DeferredSave(this.jsonFile.path,
                                             () => JSON.stringify(this),
                                             ASYNC_SAVE_DELAY_MS);
     }
 
     let promise = this._deferredSave.saveChanges();
     if (!this._schemaVersionSet) {
       this._schemaVersionSet = true;
-      promise.then(
+      promise = promise.then(
         count => {
           // Update the XPIDB schema version preference the first time we successfully
           // save the database.
           logger.debug("XPI Database saved, setting schema version preference to " + DB_SCHEMA);
           Services.prefs.setIntPref(PREF_DB_SCHEMA, DB_SCHEMA);
           // Reading the DB worked once, so we don't need the load error
           this._loadError = null;
         },
         error => {
           // Need to try setting the schema version again later
           this._schemaVersionSet = false;
-          logger.warn("Failed to save XPI database", error);
           // this._deferredSave.lastError has the most recent error so we don't
           // need this any more
           this._loadError = null;
+
+          throw error;
         });
     }
+
+    promise.catch(error => {
+      logger.warn("Failed to save XPI database", error);
+    });
   },
 
   flush: function() {
     // handle the "in memory only" and "saveChanges never called" cases
     if (!this._deferredSave) {
       return Promise.resolve(0);
     }