Bug 1389381 - Part 1: Synchronously remove rending responses after aborting them. r=aswan, a=sledru
authorKris Maglione <maglione.k@gmail.com>
Fri, 11 Aug 2017 14:37:53 -0700
changeset 421167 3323f34f84bb5303aeb01dc6dd07d7ccb1abefb4
parent 421166 fc583fa366b03d3f691290293c2e57425f30d23a
child 421168 ffabdaaebceac4ac77c595703494b6f919d998e8
push id7612
push userryanvm@gmail.com
push dateMon, 14 Aug 2017 14:21:34 +0000
treeherdermozilla-beta@b301a9babee6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, sledru
bugs1389381
milestone56.0
Bug 1389381 - Part 1: Synchronously remove rending responses after aborting them. r=aswan, a=sledru Pending responses are normally removed by the response's promise handlers. But since promise handlers are called asynchronously, multiple calls to abortResponses can wind up handling the same already-aborted responses when called before we process the microtask queue. MozReview-Commit-ID: 4jy0O7PaoqP
toolkit/components/extensions/MessageChannel.jsm
--- a/toolkit/components/extensions/MessageChannel.jsm
+++ b/toolkit/components/extensions/MessageChannel.jsm
@@ -777,16 +777,17 @@ this.MessageChannel = {
    * @param {object} [reason]
    *    An optional object describing the reason the response was aborted.
    *    Will be passed to the promise rejection handler of all aborted
    *    responses.
    */
   abortResponses(sender, reason = this.REASON_DISCONNECTED) {
     for (let response of this.pendingResponses) {
       if (this.matchesFilter(sender, response.sender)) {
+        this.pendingResponses.delete(response);
         this.abortedResponses.add(response.channelId);
         response.reject(reason);
       }
     }
   },
 
   /**
    * Aborts any pending message responses to the broker for the given