From c18a4189af11ccd11fc19134f105861b4e0f5352 Mon Sep 17 00:00:00 2001 From: ztimson Date: Sat, 27 Jun 2026 13:44:33 -0400 Subject: [PATCH] Catch ADSB timeouts --- README.md | 1 + server/src/adsb.mjs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c84d532..508cc7d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ## TODO +- Proxy ICAO lookups on failure - Make sure openmeteo properties match + we backfill any missing - Fix daily (missing future dates + timestamp on 24 hour forecast is wrong) - Update openapi doc diff --git a/server/src/adsb.mjs b/server/src/adsb.mjs index e154492..ddea59d 100644 --- a/server/src/adsb.mjs +++ b/server/src/adsb.mjs @@ -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 || [];