2024-11-23 19:12:00 +01:00
|
|
|
// 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.
|
2024-11-24 20:07:26 +01:00
|
|
|
|
|
|
|
let shouldReload = true;
|
|
|
|
addEventListener("beforeunload", () => {
|
|
|
|
shouldReload = false;
|
|
|
|
});
|
|
|
|
|
2024-11-23 19:12:00 +01:00
|
|
|
await fetch("/dev/live-reload/stall").catch(async () => {
|
2024-11-24 20:07:26 +01:00
|
|
|
while (shouldReload) {
|
2024-11-23 19:12:00 +01:00
|
|
|
try {
|
|
|
|
let response = await fetch("/dev/live-reload/back-up");
|
|
|
|
if (response.status == 200) {
|
|
|
|
window.location.reload();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|