Bug 1368650 - Prevent frozen request when actor throws. r=bgrins draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 06 Nov 2017 15:18:35 -0800
changeset 693853 795030b0e4c5173c768e6c9f1bbcc7b403bcf202
parent 693347 e64846245b002c204144ac412fbd874e32e47edf
child 693854 dff2094195bfdc3493e8f254004b10421a6d59f2
push id87939
push userbmo:poirot.alex@gmail.com
push dateMon, 06 Nov 2017 23:35:59 +0000
reviewersbgrins
bugs1368650
milestone58.0a1
Bug 1368650 - Prevent frozen request when actor throws. r=bgrins When an exception happen, the server replies with {"error":"unknownError"} message, but without any actorID. It is considered as an unsolicited message. The original client request that ends up throwing on the server ends up never resolving. By passing back "actor" with the original actorID being requested, we allow the client to resolve with an error. MozReview-Commit-ID: Luow4SzqsBP
devtools/server/main.js
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -1785,19 +1785,20 @@ DebuggerServerConnection.prototype = {
     if (packet.type == "requestTypes") {
       ret = { from: actor.actorID, requestTypes: Object.keys(actor.requestTypes) };
     } else if (actor.requestTypes && actor.requestTypes[packet.type]) {
       // Dispatch the request to the actor.
       try {
         this.currentPacket = packet;
         ret = actor.requestTypes[packet.type].bind(actor)(packet, this);
       } catch (e) {
-        this.transport.send(this._unknownError(
-          "error occurred while processing '" + packet.type,
-          e));
+        let errorPacket = this._unknownError(
+          "error occurred while processing '" + packet.type, e);
+        errorPacket.from = packet.to;
+        this.transport.send(errorPacket);
       } finally {
         this.currentPacket = undefined;
       }
     } else {
       ret = { error: "unrecognizedPacketType",
               message: ("Actor " + actor.actorID +
                         " does not recognize the packet type " +
                         packet.type) };