Skip to content

Commit

Permalink
Bug 1872770: Allowing the MessagePort ForceClose message to be not in…
Browse files Browse the repository at this point in the history
… sync with the previous messages sent on the port.r=edenchuang

As described here, https://bugzilla.mozilla.org/show_bug.cgi?id=1872770#c10 the MessagePort ForceClose message can be out of sync
in certain situations and hence, the sequenceIDs could be different. This is fine as we don't expect to receive more messages after
the ForceClose.

Differential Revision: https://phabricator.services.mozilla.com/D200014
  • Loading branch information
hsingh-moz committed Feb 5, 2024
1 parent 5e5508c commit 5f5f222
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions dom/messagechannel/MessagePortService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,15 @@ bool MessagePortService::ForceClose(const nsID& aUUID,
return true;
}

if (!data->mDestinationUUID.Equals(aDestinationUUID) ||
data->mSequenceID != aSequenceID) {
NS_WARNING("DestinationUUID and/or sequenceID do not match.");
return false;
}
NS_ENSURE_TRUE(data->mDestinationUUID.Equals(aDestinationUUID), false);

// If StructuredCloneData includes a MessagePort, StructuredCloneData
// serialization failure in postMessage can trigger MessagePort::ForceClose().
// And since the serialized port transfered has started but not finished yet,
// the SequenceID will not be synchronized to the parent side, which will
// cause the SequenceID to mismatch here. See bug 1872770.
NS_WARNING_ASSERTION(data->mSequenceID == aSequenceID,
"sequence IDs do not match");

CloseAll(aUUID, true);
return true;
Expand Down

0 comments on commit 5f5f222

Please sign in to comment.