Catch ADSB timeouts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
## TODO
|
## TODO
|
||||||
|
- Proxy ICAO lookups on failure
|
||||||
- Make sure openmeteo properties match + we backfill any missing
|
- Make sure openmeteo properties match + we backfill any missing
|
||||||
- Fix daily (missing future dates + timestamp on 24 hour forecast is wrong)
|
- Fix daily (missing future dates + timestamp on 24 hour forecast is wrong)
|
||||||
- Update openapi doc
|
- Update openapi doc
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ setInterval(() => {
|
|||||||
}
|
}
|
||||||
}, 1000 * 60 * 5);
|
}, 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() {
|
async function syncMilitaryRanges() {
|
||||||
const { ADSB_URL } = cfg();
|
const { ADSB_URL } = cfg();
|
||||||
try {
|
try {
|
||||||
@@ -194,7 +200,7 @@ export async function enrichAircraft(a) {
|
|||||||
export async function getADSB() {
|
export async function getADSB() {
|
||||||
const { ADSB_URL } = cfg();
|
const { ADSB_URL } = cfg();
|
||||||
if (!ADSB_URL) return [];
|
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 j = await r.json();
|
||||||
const aircraft = j.aircraft || [];
|
const aircraft = j.aircraft || [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user