fix(map): open a day the routing relay could not answer drawn, without waiting for it again

On an instance that routes its days with Valhalla (the TREK services by
default), a day the relay could not answer in time was drawn by OSRM and
kept only under the OSRM key. The next visit missed the Valhalla key, asked
the relay again and waited out its deadline, up to twelve seconds a day,
before the kept road showed, so every reload showed straight lines first.

OSRM's answer now stands in for such a day for an hour under a key of its
own, on the device only. Reopening the trip draws it at once; after the
hour the relay is asked again and its answer becomes the day's. Days that
avoid something keep asking Valhalla, since the stand-in drives the road
they mean to leave out.

Closes #3228
This commit is contained in:
Maurice
2026-11-26 22:09:59 +01:00
parent 7d802081ce
commit 10d95a39ac
4 changed files with 69 additions and 5 deletions
+18
View File
@@ -39,3 +39,21 @@ export async function storedRoute(key: string): Promise<RouteWithLegs | null> {
if (kept) rememberRoute(key, kept);
return kept;
}
/**
* How long OSRM's answer stands in for a day Valhalla could not route. Long enough that
* reopening the trip draws that day at once instead of waiting out the relay again on
* every visit (#3228), short enough that a Valhalla back from an outage gets the day again
* the same day.
*/
const STAND_IN_MS = 60 * 60 * 1000;
/** Keeps OSRM's answer for a day Valhalla could not route, on the device only, for `STAND_IN_MS`. */
export function keepStandIn(key: string, route: RouteWithLegs): void {
void routeCacheRepo.put(key, route);
}
/** The answer that stood in for a day Valhalla could not route, while it is recent enough. */
export function standIn(key: string): Promise<RouteWithLegs | null> {
return routeCacheRepo.get<RouteWithLegs>(key, STAND_IN_MS);
}