From f82a50325ed7079540cde9db03f3a336377ae2f9 Mon Sep 17 00:00:00 2001 From: regularfellow <59539975+regularfellow@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:54:13 +0000 Subject: [PATCH 1/2] add timeout for retries to prevent retry request from hanging indefinitely --- assets/polling.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/polling.html b/assets/polling.html index 1d63c74..5b3ad56 100644 --- a/assets/polling.html +++ b/assets/polling.html @@ -5,11 +5,14 @@ unloaded = true; }}); - const retry = (url) => - fetch(url, {{ cache: "no-store" }}) + const retry = (url) => {{ + const controller = new AbortController(); + const timeoutId = 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" }}) From 6e7b8336d5f0dc5681a5fe19feaf401a32977e09 Mon Sep 17 00:00:00 2001 From: Leo Gaskin Date: Sun, 28 Jan 2024 15:57:23 +0100 Subject: [PATCH 2/2] Remove unused variable --- assets/polling.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/polling.html b/assets/polling.html index 5b3ad56..77db4cb 100644 --- a/assets/polling.html +++ b/assets/polling.html @@ -7,7 +7,7 @@ const retry = (url) => {{ const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), 500); + setTimeout(() => controller.abort(), 500); fetch(url, {{ cache: "no-store", signal: controller.signal }}) .then(() => console.log("[tower-livereload] reload...")) .then(() => window.location.reload())