diff --git a/client/src/components/Map/RouteCalculator.ts b/client/src/components/Map/RouteCalculator.ts index 032dc0f32..4c35c1b6d 100644 --- a/client/src/components/Map/RouteCalculator.ts +++ b/client/src/components/Map/RouteCalculator.ts @@ -317,8 +317,8 @@ async function valhallaOrOsrmDay( const plain = (await storedRoute(keys.plain)) ?? await osrmWithLegs(waypoints, keys.coords, profile, signal) cacheRoute(keys.plain, plain) const drawn = withFallbackNoted(plain, avoiding) - // A day left before Valhalla answered was never refused by it. - if (standInKey && !signal?.aborted) keepStandIn(standInKey, drawn) + // A day left before Valhalla answered, or never put to it, was not refused by it. + if (standInKey && asking && !signal?.aborted) keepStandIn(standInKey, drawn) return drawn } diff --git a/client/src/components/Map/valhallaDayRoute.test.ts b/client/src/components/Map/valhallaDayRoute.test.ts index 5d00c44fa..c422565d2 100644 --- a/client/src/components/Map/valhallaDayRoute.test.ts +++ b/client/src/components/Map/valhallaDayRoute.test.ts @@ -314,6 +314,21 @@ describe('the route cache keeps the engine apart', () => { }); describe('the route cache while the relay rests', () => { + it('VDAY-CACHE-006: a day drawn by OSRM while the relay rested is asked again as soon as it is back', async () => { + let up = false; + const traffic = listen((body) => (up ? answered(body) : HttpResponse.json({ error: 'down' }, { status: 503 }))); + await calculateRouteWithLegs(freshDay(2), { profile: 'driving' }); + const points = freshDay(3); + expect((await calculateRouteWithLegs(points, { profile: 'driving' })).engine).toBe('osrm'); + expect(traffic.relay).toHaveLength(1); + + up = true; + resetValhallaTurns(); + const routed = await calculateRouteWithLegs(points, { profile: 'driving' }); + expect([routed.distance, routed.engine]).toEqual([4000, 'valhalla']); + expect(traffic.relay).toHaveLength(2); + }); + it('VDAY-CACHE-003: a day kept from Valhalla is still found while the relay rests, as it is offline', async () => { const points = freshDay(3); let up = true;