Catch ADSB timeouts

This commit is contained in:
2026-06-27 13:44:33 -04:00
parent c5477d05ad
commit c18a4189af
2 changed files with 8 additions and 1 deletions

View File

@@ -33,6 +33,12 @@ setInterval(() => {
}
}, 1000 * 60 * 5);
function fetchWithTimeout(url, ms = 5000) {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), ms);
return fetch(url, { signal: controller.signal }).finally(() => clearTimeout(id));
}
async function syncMilitaryRanges() {
const { ADSB_URL } = cfg();
try {
@@ -194,7 +200,7 @@ export async function enrichAircraft(a) {
export async function getADSB() {
const { ADSB_URL } = cfg();
if (!ADSB_URL) return [];
const r = await fetch(`${ADSB_URL}:8080/data/aircraft.json`);
const r = await fetchWithTimeout(`${ADSB_URL}:8080/data/aircraft.json`);
const j = await r.json();
const aircraft = j.aircraft || [];