From 74387ff92bf8f8bfdbd9a0361e8f92816dc9e600 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 24 Jun 2022 14:50:00 +0200 Subject: [PATCH] fix: don't reload multiple times on restart (#283) --- src/server/context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/context.ts b/src/server/context.ts index 484475b7..bbaa3c45 100644 --- a/src/server/context.ts +++ b/src/server/context.ts @@ -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",