Skip to content

Commit

Permalink
fix: add timeout for updating state
Browse files Browse the repository at this point in the history
Signed-off-by: Alan D. Tse <alandtse@gmail.com>
  • Loading branch information
alandtse committed Oct 5, 2019
1 parent 4887441 commit 853e4bf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,21 @@ function handleMessage(request, sender, sendResponse) {
};
} else comparequeue.push({ selection: selection, tabId: activeTabId });
status[activeTabId] = "Pending";
if (updating) {
var timeElapsed = updating ? Date.now() - updating : 0;
if (updating && timeElapsed <= 120000) {
console.log(
"Update pending; queing compare for tab %s; %s queued",
"Update pending %s seconds; queing compare for tab %s; %s queued",
(timeElapsed / 1000).toFixed(2),
activeTabId,
comparequeue.length
);
} else if (updating) {
console.log(
"Update pending %s seconds exceeded timeout; forcing load list; %s queued",
(timeElapsed / 1000).toFixed(2),
comparequeue.length
);
loadList();
} else {
console.log(
"License load needed; queing compare for tab %s; %s queued",
Expand Down Expand Up @@ -591,7 +600,7 @@ function updateList() {
if (updating) {
console.log("Ignoring redundant update request");
} else {
updating = true;
updating = Date.now();
licensesLoaded = 0;
dowork({ command: "updatelicenselist" });
}
Expand Down

0 comments on commit 853e4bf

Please # to comment.