From be70f5e2e9733eafb9ef5417ff956c54816058cd Mon Sep 17 00:00:00 2001 From: afterlifepro Date: Mon, 28 Jul 2025 15:47:00 +0100 Subject: [PATCH] Resolve error "The connection to http://localhost:3000/now-playing-sse was interrupted while the page was loading." --- src/components/playing/NowPlaying.astro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/playing/NowPlaying.astro b/src/components/playing/NowPlaying.astro index 405646c..e379bd9 100644 --- a/src/components/playing/NowPlaying.astro +++ b/src/components/playing/NowPlaying.astro @@ -632,6 +632,9 @@ const dataTrack = ( const ev = new EventSource("/now-playing-sse"); + // close event source safely + window.addEventListener("beforeunload", () => ev.close()) + let i = -1; ev.addEventListener("playing", (event) => { i++; -- 2.51.2