Bug 1389381: Part 1 - Synchronously remove rending responses after aborting them. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Fri, 11 Aug 2017 14:37:53 -0700
changeset 374319 4b63f0f44148519df73c725ab99746d4d686e12f
parent 374318 113580d267ea3cbd23001a8b19f03a6730684ff4
child 374320 364ef71685abd9959f7816810e422a15ec92087f
push id93672
push usermaglione.k@gmail.com
push dateSat, 12 Aug 2017 18:34:39 +0000
treeherdermozilla-inbound@96fb5933d073 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1389381
milestone57.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 1389381: Part 1 - Synchronously remove rending responses after aborting them. r=aswan 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