aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/main.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-04-04 06:05:43 +0100
committerStephen Blott2016-04-04 06:15:52 +0100
commitcc4e02d04adb60743fe20102ec40324aa622bcd1 (patch)
tree5c548e3c06d9a3b70b725f2189c6e5401315512e /background_scripts/main.coffee
parentca89992afd75e98db07e931d9e978f7ed678a137 (diff)
downloadvimium-cc4e02d04adb60743fe20102ec40324aa622bcd1.tar.bz2
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.
Diffstat (limited to 'background_scripts/main.coffee')
-rw-r--r--background_scripts/main.coffee6
1 files changed, 4 insertions, 2 deletions
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"