From cc4e02d04adb60743fe20102ec40324aa622bcd1 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 4 Apr 2016 06:05:43 +0100 Subject: Better handling of port failures. If we lose contact with a frame (it's goine away) while still awaiting hints from that frame, then post a dummy/empty list of hints instead. This seems very unlikely to come up, but we should guard against it anyway. We use "nextTick()" so that we finish sending the current message before sending the dummy hints. --- background_scripts/main.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 1f6f1c0b..ab7e881a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -363,9 +363,11 @@ HintCoordinator = try port.postMessage request catch - # If a frame has gone away, then we remove it from consideration. - tabState[tabId].frameIds = tabState[tabId].frameIds.filter (fId) -> fId != frameId + # A frame has gone away; remove it from consideration. delete @tabState[tabId].ports[frameId] + # It could be that we're expecting hints from this frame; schedule "sending" dummy/empty hints instead. + Utils.nextTick => + @postHintDescriptors tabId, frameId, {hintDescriptors: []} if frameId in tabState[tabId].frameIds # We can delete the tab state when we see an "exit" message, that's the last message in the sequence. delete @tabState[tabId] if messageType == "exit" -- cgit v1.2.3