Bug 1442312 - Finish DevTools server conversion to DOM Promises. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 07 Mar 2018 16:52:51 -0600
changeset 462513 fbc3768c446ad1b74439e6a16e08e353656b1c0c
parent 462512 31d94cfa44e855ad81fb70779f6568ed902e930e
child 462514 3ca7ee7f010fbb8e85fbe5dc71edfe61fa15c8dd
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1442312
milestone60.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 1442312 - Finish DevTools server conversion to DOM Promises. r=ochameau Remove the last sync promises from the server. This causes server replies to be sent later than before, potentially later enough that the connection has since been closed. We now throw errors in such cases. MozReview-Commit-ID: 2x213g7poH5
devtools/server/main.js
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -12,17 +12,16 @@ var { Ci, Cc } = require("chrome");
 var Services = require("Services");
 var { ActorPool, OriginalLocation, RegisteredActorFactory,
       ObservedActorFactory } = require("devtools/server/actors/common");
 var { LocalDebuggerTransport, ChildDebuggerTransport, WorkerDebuggerTransport } =
   require("devtools/shared/transport/transport");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
 var { dumpn } = DevToolsUtils;
 var flags = require("devtools/shared/flags");
-var SyncPromise = require("devtools/shared/deprecated-sync-thenables");
 
 DevToolsUtils.defineLazyGetter(this, "DebuggerSocket", () => {
   let { DebuggerSocket } = require("devtools/shared/security/socket");
   return DebuggerSocket;
 });
 DevToolsUtils.defineLazyGetter(this, "Authentication", () => {
   return require("devtools/shared/security/auth");
 });
@@ -1626,25 +1625,33 @@ DebuggerServerConnection.prototype = {
     dumpn(errorString);
     return {
       error: "unknownError",
       message: errorString
     };
   },
 
   _queueResponse: function (from, type, responseOrPromise) {
-    let pendingResponse = this._actorResponses.get(from) || SyncPromise.resolve(null);
+    let pendingResponse = this._actorResponses.get(from) || Promise.resolve(null);
     let responsePromise = pendingResponse.then(() => {
       return responseOrPromise;
     }).then(response => {
+      if (!this.transport) {
+        throw new Error(`Connection closed, pending response from ${from}, ` +
+                        `type ${type} failed`);
+      }
       if (!response.from) {
         response.from = from;
       }
       this.transport.send(response);
     }).catch((e) => {
+      if (!this.transport) {
+        throw new Error(`Connection closed, pending error from ${from}, ` +
+                        `type ${type} failed`);
+      }
       let errorPacket = this._unknownError(
         "error occurred while processing '" + type, e);
       errorPacket.from = from;
       this.transport.send(errorPacket);
     });
 
     this._actorResponses.set(from, responsePromise);
   },
@@ -1656,17 +1663,17 @@ DebuggerServerConnection.prototype = {
    *        The ID of the add-on to pass the options to
    * @param options object
    *        The options.
    * @return a promise that will be resolved when complete.
    */
   setAddonOptions(id, options) {
     let addonList = this.rootActor._parameters.addonList;
     if (!addonList) {
-      return SyncPromise.resolve();
+      return Promise.resolve();
     }
     return addonList.getList().then((addonActors) => {
       for (let actor of addonActors) {
         if (actor.id != id) {
           continue;
         }
         actor.setOptions(options);
         return;