Events
Tasks can pause until an external event arrives before continuing. This is the foundation for human-in-the-loop workflows, webhook-driven pipelines, and any flow that depends on signals from outside the task.
Both durable tasks and DAGs support waiting for events. Durable tasks call WaitForEvent dynamically at runtime, while DAGs declare event conditions upfront on the task definition.
Events are delivered by pushing events into Hatchet using the event client. The event key you push must match the key your task is waiting for.
Wait For Events
Wait For Events lets a durable task pause until an external event arrives. Even if the task is interrupted and requeued while waiting, the event will still be processed. When it resumes, it reads the event from the durable event log and continues.
Waiting for an event puts the task into an evictable state, the worker slot is freed and the task is re-queued when the event arrives.
Declaring a wait for event
Wait For Event is declared using the context method WaitFor (or utility method WaitForEvent) on the DurableContext object.
Event filters
Events can be filtered using CEL expressions. For example, to only receive user:update events for a specific user:
Pushing events
For a waiting task to resume, something must push an event into Hatchet with a matching key. You can do this from any service that has access to the Hatchet client.
When the pushed event’s key matches what a durable task is waiting for (and passes any CEL filter), the task is re-queued and resumes from its checkpoint.