Skip to content

Commit

Permalink
Merge pull request #8 from regularfellow/master
Browse files Browse the repository at this point in the history
Add timeout for retries to prevent retry request from hanging
  • Loading branch information
leotaku authored Jan 28, 2024
2 parents 76981cc + 6e7b833 commit d7996a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/polling.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
unloaded = true;
}});

const retry = (url) =>
fetch(url, {{ cache: "no-store" }})
const retry = (url) => {{
const controller = new AbortController();
setTimeout(() => controller.abort(), 500);
fetch(url, {{ cache: "no-store", signal: controller.signal }})
.then(() => console.log("[tower-livereload] reload..."))
.then(() => window.location.reload())
.catch(() => setTimeout(() => retry(url), {reload_interval}));
.catch(() => setTimeout(() => retry(url), {reload_interval}))
}};

const main = () =>
fetch("{long_poll}", {{ cache: "no-store" }})
Expand Down

0 comments on commit d7996a8

Please sign in to comment.