Step: While
- Key:
while - Category: Workflow Control
- Description: Repeat nested steps while a condition evaluates to true.
Inputs
condition(long-text, required): JavaScript-style expression evaluated against the current flow context, for exampleretryCount < 3 && status !== "done".maxIterations(number, optional): Safety limit for loop runs. The default is200; the runtime caps the value at2000.
Loop Context
During each iteration, nested steps can read:
iteration: Zero-based iteration index._while: Object containingiteration,run, andisFirst.
The runtime restores any previous iteration and _while values after the loop finishes.
Outputs
iterations(number): Number of completed iterations.results(array): Per-iteration nested step results.errors(array): Condition evaluation errors, nested step errors, or max-iteration errors.lastIteration(object | null): Last iteration result, ornullif nothing ran.
Notes
- The condition is checked before each iteration.
- Make sure nested steps update the variables used by
condition; otherwise the loop runs untilmaxIterationsis reached. - Prefer
eachwhen you already have a fixed array. Usewhilefor polling, retries, countdowns, and condition-based workflows.
Example Use Cases
Retry until success: Poll an external API and keep looping while status !== "completed".
Countdown: Decrement a numeric variable until the condition becomes false.
Pagination: Fetch a page, append the results to an array, update nextPage, and stop when no next page remains.

