From c5982e905f76161433f682e7a212bde49aa9e8c1 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Mon, 10 Aug 2026 03:25:14 -0400 Subject: [PATCH] fix(geocode): replace AbortSignal.timeout with AbortController for compatibility - AbortSignal.timeout not supported on all mobile browsers - Manual AbortController + setTimeout works everywhere - Fixes location not showing on dashboard and history first point Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- static/js/history.js | 8 +++++--- static/js/yaris.js | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/static/js/history.js b/static/js/history.js index b50c714..c9f9c1b 100644 --- a/static/js/history.js +++ b/static/js/history.js @@ -32,10 +32,12 @@ if (key === _lastGeoKey) return; _lastGeoKey = key; const fallback = `${lat.toFixed(5)}, ${lon.toFixed(5)}`; - fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: AbortSignal.timeout(4000) }) - .then(r => r.ok ? r.json() : null) + const ctrl = new AbortController(); + const t = setTimeout(() => ctrl.abort(), 6000); + fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: ctrl.signal }) + .then(r => { clearTimeout(t); return r.ok ? r.json() : null; }) .then(data => { replayLocation.textContent = (data && data.label) ? data.label : fallback; }) - .catch(() => { replayLocation.textContent = fallback; }); + .catch(() => { clearTimeout(t); replayLocation.textContent = fallback; }); } function scheduleGeocode(lat, lon) { diff --git a/static/js/yaris.js b/static/js/yaris.js index f927558..43a4c4f 100644 --- a/static/js/yaris.js +++ b/static/js/yaris.js @@ -199,10 +199,12 @@ _recenterBtn.addEventListener('click', function () { function reverseGeocode(lat, lon) { const el = document.getElementById('gps-location-name'); const fallback = `${lat.toFixed(5)}, ${lon.toFixed(5)}`; - fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: AbortSignal.timeout(6000) }) - .then(r => r.ok ? r.json() : null) + const ctrl = new AbortController(); + const t = setTimeout(() => ctrl.abort(), 6000); + fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: ctrl.signal }) + .then(r => { clearTimeout(t); return r.ok ? r.json() : null; }) .then(data => { el.textContent = (data && data.label) ? data.label : fallback; }) - .catch(() => { el.textContent = fallback; }); + .catch(() => { clearTimeout(t); el.textContent = fallback; }); } function _movedEnough(lat, lon) {