From 3317a64bc66c80eae20264c6ea48d3adc203369a Mon Sep 17 00:00:00 2001 From: you Date: Sun, 22 Mar 2026 04:52:45 +0000 Subject: [PATCH] fix: null-guard animLayer/pathsLayer in animation cleanup setInterval callbacks fire after navigating away from live map, when layers are already destroyed. --- public/index.html | 2 +- public/live.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 07b4bbc1..78e058ee 100644 --- a/public/index.html +++ b/public/index.html @@ -90,7 +90,7 @@ - + diff --git a/public/live.js b/public/live.js index ecf24427..f291c547 100644 --- a/public/live.js +++ b/public/live.js @@ -1685,13 +1685,12 @@ if (step >= steps) { clearInterval(interval); - animLayer.removeLayer(dot); + if (animLayer) animLayer.removeLayer(dot); recentPaths.push({ line, glowLine: contrail, time: Date.now() }); while (recentPaths.length > 5) { const old = recentPaths.shift(); - pathsLayer.removeLayer(old.line); - pathsLayer.removeLayer(old.glowLine); + if (pathsLayer) { pathsLayer.removeLayer(old.line); pathsLayer.removeLayer(old.glowLine); } } setTimeout(() => { @@ -1700,8 +1699,7 @@ fadeOp -= 0.1; if (fadeOp <= 0) { clearInterval(fi); - pathsLayer.removeLayer(line); - pathsLayer.removeLayer(contrail); + if (pathsLayer) { pathsLayer.removeLayer(line); pathsLayer.removeLayer(contrail); } recentPaths = recentPaths.filter(p => p.line !== line); } else { line.setStyle({ opacity: fadeOp });