mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
fix(server): give the last six outbound fetches a timeout, and lint for it
Overpass, the Wikipedia photo lookup (which holds one of five shared photo slots), the plugin download and registry, and the two API key checks had no signal, so a provider that took the connection and went quiet held the request for undici's 300 s default. ESLint now refuses a fetch() whose init carries no signal.
This commit is contained in:
@@ -1469,6 +1469,9 @@ export class MapsService {
|
||||
method: 'POST',
|
||||
headers: { 'User-Agent': UA, 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: `data=${encodeURIComponent(query)}`,
|
||||
// The query asks Overpass for 5 s; a public instance that is overloaded
|
||||
// takes the connection and then sits on it.
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const data = (await res.json()) as { elements?: OverpassElement[] };
|
||||
@@ -1615,7 +1618,12 @@ export class MapsService {
|
||||
pilimit: '1',
|
||||
redirects: '1',
|
||||
});
|
||||
const res = await fetch(`https://en.wikipedia.org/w/api.php?${searchParams}`, { headers: { 'User-Agent': UA } });
|
||||
const res = await fetch(`https://en.wikipedia.org/w/api.php?${searchParams}`, {
|
||||
headers: { 'User-Agent': UA },
|
||||
// This runs inside one of the few shared photo-fetch slots; a stalled
|
||||
// answer would hold it for everyone.
|
||||
signal: AbortSignal.timeout(WIKI_TIMEOUT_MS),
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = (await res.json()) as { query?: { pages?: Record<string, { thumbnail?: { source?: string } }> } };
|
||||
const pages = data.query?.pages;
|
||||
|
||||
Reference in New Issue
Block a user