Skip to content

withFallback

withFallback<In, Out>(primary, fallback): Stage<In, Out>

Defined in: packages/engine/src/lib/planner/with-fallback.ts:24

Runs primary, and runs fallback with the same input and context only when primary returns a Deferred. Candidates and EngineErrors from primary are returned unchanged, so a real failure is never masked by a second attempt.

The two run one after the other: on deferral the latencies add up. Both stages share the request’s signal and must honour it.

In

Out

Stage<In, Out>

Stage<In, Out>

Stage<In, Out>

// `modelPlanner` is any `Planner`, for example one that calls a model.
const planner = withFallback(
pipeline(selectVessels, arrangeLayout),
modelPlanner,
);