Bug 1262618 - Fix an unchained promise and a couple of non-promise returns in the push service. r=wchen
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 06 Apr 2016 15:46:41 -0700
changeset 292114 04e4fbe0584e4c8d4cfb773875d60b74eeec7543
parent 292113 fbf998f960c7d4c5f44b52f2dd5473a0257cf351
child 292115 1839dee776400ef389063c87707ae40596ec77dc
push id74762
push usercbook@mozilla.com
push dateThu, 07 Apr 2016 09:56:20 +0000
treeherdermozilla-inbound@772253c53374 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswchen
bugs1262618
milestone48.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 1262618 - Fix an unchained promise and a couple of non-promise returns in the push service. r=wchen
dom/push/PushService.jsm
--- a/dom/push/PushService.jsm
+++ b/dom/push/PushService.jsm
@@ -281,17 +281,19 @@ this.PushService = {
         } else if (aData == "dom.push.connection.enabled") {
           this._stateChangeProcessEnqueue(_ =>
             this._changeStateConnectionEnabledEvent(prefs.get("connection.enabled"))
           );
         }
         break;
 
       case "idle-daily":
-        this._dropExpiredRegistrations();
+        this._dropExpiredRegistrations().catch(error => {
+          console.error("Failed to drop expired registrations on idle", error);
+        });
         break;
 
       case "perm-changed":
         this._onPermissionChange(aSubject, aData).catch(error => {
           console.error("onPermissionChange: Error updating registrations:",
             error);
         })
         break;
@@ -436,16 +438,19 @@ this.PushService = {
             return Promise.resolve();
 
           } else {
             // The new serverUri is empty or misconfigured - stop service.
             this._setState(PUSH_SERVICE_INIT);
             return this._stopService(STOPPING_SERVICE_EVENT);
           }
         }
+      default:
+        console.error("Unexpected event in _changeServerURL", event);
+        return Promise.reject(new Error(`Unexpected event ${event}`));
     }
   },
 
   /**
    * PushService initialization is divided into 4 parts:
    * init() - start listening for quit-application and serverURL changes.
    *          state is change to PUSH_SERVICE_INIT
    * startService() - if serverURL is present this function is called. It starts
@@ -566,17 +571,17 @@ this.PushService = {
    *                 state is changed to PUSH_SERVICE_INIT.
    * uninit() - stop listening for quit-application and serverURL changes.
    *            state is change to PUSH_SERVICE_UNINIT
    */
   _stopService: function(event) {
     console.debug("stopService()");
 
     if (this._state < PUSH_SERVICE_ACTIVATING) {
-      return;
+      return Promise.resolve();
     }
 
     this._stopObservers();
 
     this._service.disconnect();
     this._service.uninit();
     this._service = null;