fix: surface silent scraper failures and stop falsely claiming weather delay
The homepage was flagging every park as weather delay because calendar.ts
collapsed "fetchLiveRides returned null" into the same openRides=0 bucket as
"all rides actually closed." Meanwhile every scraper (queuetimes, sixflags
operating-hours, sixflags wait-times) was swallowing non-OK responses and
exceptions silently, so logs gave no signal which upstream was failing or how.
Add a small scraperWarn helper that emits in the same shape as backend/log.ts
(without importing it — lib/scrapers is shared with the Next frontend). Use it
in all three scrapers to record HTTP status and error name+message before each
return null. Add parksSkipped to the tier-5 summary log so we can tell when the
openParks filter is rejecting everyone vs the fetcher silently failing.
Convert calendar.ts ridesCache to a discriminated union { kind: "ok" | "unknown" }.
Weather delay only fires on { kind: "ok", openRides: 0 }; unknown entries get
a 30s TTL so we recover quickly when upstream comes back and don't thunder-herd
in the meantime.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
import { normalizeForMatch } from "../coaster-match";
|
||||
import { scraperWarn } from "./log";
|
||||
|
||||
const WAIT_TIMES_BASE = "https://d18car1k0ff81h.cloudfront.net/wait-times/park";
|
||||
|
||||
@@ -119,10 +120,23 @@ export async function fetchFastLaneWaits(
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
} as RequestInit & { next: { revalidate: number } });
|
||||
|
||||
if (!res.ok) return null;
|
||||
if (!res.ok) {
|
||||
scraperWarn("sixflags-waittimes", "fetchFastLaneWaits non-OK response", {
|
||||
apiId,
|
||||
status: res.status,
|
||||
statusText: res.statusText,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
return parseWaitTimes((await res.json()) as WTResponse);
|
||||
} catch {
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
scraperWarn("sixflags-waittimes", "fetchFastLaneWaits threw", {
|
||||
apiId,
|
||||
name: e.name,
|
||||
err: e.message,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user