From 56be35e063303656aaaca6f53bea55b7d0151b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8A=E3=81=8D=E8=90=8C?= Date: Wed, 10 Sep 2025 18:43:37 +0200 Subject: [PATCH] fix live reload not letting you navigate away from the page sometimes --- static/live-reload.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/live-reload.js b/static/live-reload.js index 1d3a1b8..068cf6a 100644 --- a/static/live-reload.js +++ b/static/live-reload.js @@ -1,8 +1,13 @@ +let shouldReload = true; +addEventListener("beforeunload", () => { + shouldReload = false; +}); + // NOTE: The server never fulfills this request, it stalls forever. // Once the connection is closed, we try to connect with the server until we establish a successful // connection. Then we reload the page. await fetch("/auto-reload/stall").catch(async () => { - while (true) { + while (shouldReload) { try { let response = await fetch("/auto-reload/back-up"); if (response.status == 200) {