WorkflowRun

wait()

run.wait({ until?, timeoutMs?, intervalMs? }) → Promise<WorkflowRun>

Polls until the run reaches one of the statuses you named. By default that includes waiting — because a run stopped for a human is not a run still working.

10 minutesevery 2 secondswaiting counts as arrived
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

untilstring[]["waiting", "succeeded", "failed", "cancelled"]

Which statuses end the wait.

timeoutMsinteger600 000

Ten minutes. Past it, timeout (408) is thrown.

intervalMsinteger2 000

How often it re-reads.

await run.wait();

if (run.data.status === "waiting") {
  const step = run.data.steps.find((s) => s.status === "waiting");
  await run.resume(step.id, { approved: true });
  await run.wait();                       // then on to the end
}
run.wait()

if run.data["status"] == "waiting":
    step = next(s for s in run.data["steps"] if s["status"] == "waiting")
    run.resume(step["id"], {"approved": True})
    run.wait()                       # then on to the end

Why waiting is in the default

A human step waits indefinitely

Without waiting in the list, the default wait would always end in a timeout on any workflow with an approval — and the timeout would look like a failure. Treating « stopped for a person » as an arrival is what makes the default useful.

Waiting only for the end

await run.wait({ until: ["succeeded", "failed", "cancelled"], timeoutMs: 30 * 60_000 });
run.wait(until=["succeeded", "failed", "cancelled"], timeout_ms=30 * 60_000)

Reasonable when something else approves the human steps. Raise the ceiling with it — a chain with an approval in it can take as long as a person takes.

The timeout does not stop the run

It throws timeout (408) and the run keeps going. Catch it and come back later with getRun() — or call cancel() if you meant to stop it.

import { IaGenifyError } from "iagenify";

try {
  await run.wait({ timeoutMs: 60_000 });
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "timeout") {
    // Still running. Keep run.id and come back.
  } else throw err;
}
from iagenify import IaGenifyError

try:
    run.wait(timeout_ms=60_000)
except IaGenifyError as error:
    if error.code != "timeout":
        raise
    # Still running. Keep run.id and come back.

Polling is free, but not instant

Each tick is a read and reads cost nothing. A shorter interval reacts faster and makes more requests — two seconds is the balance chosen.