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 414533 cdf2b7a4a822dae97bbf3bf2ffd04e365656c324
parent 414532 0a353e52e32c93eefaa3cc563c235281c2a1af61
child 414534 1b2c15264aee18d2ff1f65015cc26ef2f64fc762
push id1507
push userryanvm@gmail.com
push dateMon, 14 Aug 2017 14:29:17 +0000
treeherdermozilla-release@45ab6e362747 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, sledru
bugs1389381
milestone55.0.2
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
@@ -775,16 +775,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