Amir Kamal
04/28/2026, 2:51 AMMarvin
04/28/2026, 2:52 AMMarvin
04/28/2026, 2:53 AMprefect.flow-run.Pending
- expect prefect.flow-run.Running
- if Running does not happen within some window, trigger a cancel-flow-run action
Example:
yaml
name: Cancel long-pending flow runs
enabled: true
trigger:
type: event
posture: Proactive
after:
- prefect.flow-run.Pending
expect:
- prefect.flow-run.Running
within: 600
threshold: 1
for_each:
- prefect.resource.id
match:
prefect.resource.id: "prefect.flow-run.*"
actions:
- type: cancel-flow-run
A few important notes:
- There is not a simple built-in “pending timeout” setting on the flow/deployment itself.
- Flow timeout_seconds applies once the flow is running — it won’t help with runs stuck in Pending.
- If your runs are scheduled deployments, SLA lateness can also help for “didn’t start on time” monitoring, but it’s not as general as the automation approach.
- Cancellation behavior still depends on your worker / infrastructure being able to process the cancellation.
If you want, I can help you turn this into either:
- a Prefect UI automation setup, or
- a Python SDK example to create it programmatically.
Relevant docs:
- Automations
- Events
- Workers