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++;