fix: don't reload multiple times on restart (#283)

This commit is contained in:
Luca Casonato
2022-06-24 14:50:00 +02:00
committed by GitHub
parent 6cb2ebf7d4
commit 74387ff92b
+1 -1
View File
@@ -337,7 +337,7 @@ export class ServerContext {
if (this.#dev) {
routes[REFRESH_JS_URL] = () => {
const js =
`const buildId = "${BUILD_ID}"; new EventSource("${ALIVE_URL}").addEventListener("message", (e) => { if (e.data !== buildId) { location.reload(); } });`;
`let reloading = false; const buildId = "${BUILD_ID}"; new EventSource("${ALIVE_URL}").addEventListener("message", (e) => { if (e.data !== buildId && !reloading) { reloading = true; location.reload(); } });`;
return new Response(new TextEncoder().encode(js), {
headers: {
"content-type": "application/javascript; charset=utf-8",