mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
fix(rail): trip-update delays are as old as the server's read
The browser stamped every trip-updates answer as just read. While an operator's feed fails, the rail proxy replays its last good copy for up to ten minutes, and a cached copy can be a TTL old, so those delays never reached RAIL_UPDATES_MAX_AGE_MS and a selected train's card showed them as current. Delays now take their age from the snapshot's fetchedAt (capped at now), as positions do in ingestion.js, so they stop applying 75 s after the server last read the operator.
This commit is contained in:
1 parent
ace2160002
commit
283890cee0
2 files changed
+58
-1
No files matched your search
@@ -287,8 +287,16 @@ export function createRailSchedules({
|
||||
if (!response.ok) throw new Error(`rail updates HTTP ${response.status}`);
|
||||
const body = await response.json();
|
||||
if (slot.controller !== controller) return;
|
||||
// Delays are as old as the server's read of the operator (`fetchedAt`),
|
||||
// not this answer: a cached copy, or the last good one replayed while
|
||||
// the operator fails, stops applying RAIL_UPDATES_MAX_AGE_MS after it,
|
||||
// as positions do (ingestion.js applySnapshot).
|
||||
const at = now();
|
||||
slot.delays = delaysFromUpdates(body);
|
||||
slot.at = now();
|
||||
slot.at = Math.min(
|
||||
Number.isFinite(body?.fetchedAt) ? body.fetchedAt : at,
|
||||
at,
|
||||
);
|
||||
onChange(feedId);
|
||||
} catch (error) {
|
||||
if (error?.name !== 'AbortError')
|
||||
|
||||
Reference in new issue
Block a user