fix(client): narrow the route profile and Valhalla answer types, keep the stop check reading the whole log

The built-in profile check returned the open profile key and the run request
returned an unnarrowed answer, both of which the client typecheck refused. The
new road trip tests asserted with non-null assertions where optional calls do.

The graceful stop step piped docker logs into grep -q under pipefail, so grep
leaving early after its match could fail the step with SIGPIPE although the
server had logged SIGTERM.
This commit is contained in:
Maurice
2026-10-29 12:38:35 +01:00
committed by Maurice
parent 10e0e59c3f
commit c4a39171f2
4 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -1202,7 +1202,7 @@ jobs:
docker stop -t 30 trek-ci >/dev/null
code="$(docker inspect -f '{{.State.ExitCode}}' trek-ci)"
[ "$code" = "0" ] || { echo "::error::docker stop ended with exit code $code, not a graceful shutdown"; exit 1; }
docker logs trek-ci 2>&1 | grep -q 'SIGTERM received' \
docker logs trek-ci 2>&1 | grep 'SIGTERM received' >/dev/null \
|| { echo "::error::the server never saw SIGTERM"; exit 1; }
- name: Container log
+6 -1
View File
@@ -217,7 +217,12 @@ export function parsePluginProfile(profile: string): { pluginId: string; profile
/** One of the three profiles both engines know, or null for a plugin's own. */
function builtInProfile(profile: RouteProfileKey): 'driving' | 'walking' | 'cycling' | null {
return profile === 'driving' || profile === 'walking' || profile === 'cycling' ? profile : null
switch (profile) {
case 'driving': return 'driving'
case 'walking': return 'walking'
case 'cycling': return 'cycling'
default: return null
}
}
/**
+2 -1
View File
@@ -738,7 +738,8 @@ async function requestRun(
): Promise<Omit<ValhallaRun, 'snapped'> | ValhallaNoPath | TooSlow | null> {
const body = routeBody(waypoints, profile, avoid, costingOptions, searchFilter)
const data = await postRoute(base, body, signal, publicFallback)
if (data === NO_PATH || tooSlow(data)) return data
if (data === NO_PATH) return NO_PATH
if (tooSlow(data)) return data
return data === null ? null : runFrom(data)
}
@@ -1182,11 +1182,11 @@ describe('a leg asked for again on demand', () => {
const { result } = renderHook(() => useRoadtripRoutes(7, [day(1, 1)], map(1, [{ id: 1, at: HAMBURG }, { id: 2, at: BERLIN }])))
await waitFor(() => expect(result.current.loading).toBe(false))
const [from, to] = result.current.days[0].stops
expect(result.current.legRouter!(from, to, 1)).toMatchObject({ engine: 'osrm', standIn: false })
expect(result.current.legRouter?.(from, to, 1)).toMatchObject({ engine: 'osrm', standIn: false })
calculateRouteWithLegs.mockResolvedValue({ ...routed(1), engine: 'valhalla' })
act(() => { result.current.reroute!() })
await waitFor(() => expect(result.current.legRouter!(from, to, 1).engine).toBe('valhalla'))
act(() => { result.current.reroute?.() })
await waitFor(() => expect(result.current.legRouter?.(from, to, 1)?.engine).toBe('valhalla'))
})
it('FE-ROADTRIP-ROUTES-048: a day the stand-in engine drove while avoiding says the avoidance did not happen', async () => {