# Suspend for timers, events and human approval

Persist continuations without holding workers and resume using exact correlation or validated Inbox decisions.

Canonical URL: https://opennodeflow.dev/wiki/durable-waits/
JSON reference: https://opennodeflow.dev/wiki/durable-waits/index.json
Source snapshot: 2026-10-23

Durable Timer, Wait for Event and Human Approval suspend a run through the engine. They do not hold a sleep promise, child process, worker slot or active-run slot while waiting. Successful upstream results and the pinned execution graph remain in an encrypted continuation.

## Choose the wait

| Operation | Important inputs |
| --- | --- |
| Durable Timer | `durationMs` |
| Wait for Event | `eventKey`, `correlationKey`, optional `timeoutMs` |
| Human Approval | `title`, optional description, assignee, options and timeout |

All have optional exec and next control sockets. Durations are bounded to 365 days; event/approval timeout zero or omitted means no deadline. Scheduler checks are periodic, so timer completion is not a real-time guarantee. An overdue persisted timer becomes eligible after recovery.

Outputs include `value` and `timedOut`; approval also returns `taskId`. A normal timer returns null and false. Event/approval expiry returns null and true. Approval value contains decision and optional value. Use compatible decoders when downstream code requires a named type.

## Exact event matching

Submit a synthetic event using the runtime endpoint:

```json
{
  "workspaceId":"ws_example",
  "eventKey":"document.reviewed",
  "correlationKey":"document-123",
  "eventId":"delivery-456",
  "payload":{"approved":true}
}
```

POST this object to `/api/runtime/events`. Workspace, event name and correlation key must all match exactly and case-sensitively. Every currently pending matching wait resumes, so choose unique correlation keys when only one run should continue.

Delivery IDs are durable within a workspace. Repeating the same ID and exact request returns its original receipt; changing the data under that ID conflicts. Preserve stable identity after an uncertain response. An unmatched event is not held for a future wait: use [storage/queues](/wiki/storage/) when early-arriving events need durable consumption.

## Inbox decisions

Human Approval creates a persisted Inbox task. Default decisions are approve/reject; configured options must be distinct nonempty strings. Assignee is a display/routing hint, not an authenticated identity or permission rule.

Complete the task with its current revision and exact offered decision. Completion, wait transition and scheduling are atomic. A stale or second decision conflicts. Late decisions after expiry are rejected. Approval waits cannot bypass option validation through the generic administrative resume endpoint.

Task completion itself sends no provider message; downstream nodes perform any external effect. Use storage question/actor-policy contracts for stronger business correlation.

## Recovery and limits

Waiting runs and paused debug continuations survive restart with their pins. Active arbitrary code interrupted by a crash is not automatically replayed. Preserve the database and matching encryption key together.

Durable waits are rejected inside collection/Repeat bodies. Place them before or after those bounded containers. Custom code's `context.sleep` remains an in-process delay subject to attempt timeout; it does not become durable merely because it waits.

---

## Documentation provenance

- `docs/DEBUGGING-AND-WAITS.md`
- `docs/STORAGE.md`
- `docs/BACKUP-RESTORE.md`

This page describes maintained source, not a live inventory or an authorization to perform actions.
