untilstring[]["waiting", "succeeded", "failed", "cancelled"]Which statuses end the wait.
timeoutMsinteger600 000Ten minutes. Past it, timeout (408) is thrown.
intervalMsinteger2 000How 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 endWhy waiting is in the default
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.