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
--- 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