Files
antigravity-skills-reference/skills/dbos-golang/references/workflow-timeout.md
Max dml 7e5abd504f feat: add DBOS skills for TypeScript, Python, and Go (#94)
Add three DBOS SDK skills with reference documentation for building
reliable, fault-tolerant applications with durable workflows.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 23:26:51 +01:00

1.3 KiB

title, impact, impactDescription, tags
title impact impactDescription tags
Set Workflow Timeouts CRITICAL Prevents workflows from running indefinitely workflow, timeout, cancellation, duration

Set Workflow Timeouts

Set a timeout for a workflow by using Go's context.WithTimeout or dbos.WithTimeout on the DBOS context. When the timeout expires, the workflow and all its children are cancelled.

Incorrect (no timeout for potentially long workflow):

// No timeout - could run indefinitely
handle, err := dbos.RunWorkflow(ctx, processTask, "data")

Correct (with timeout):

// Create a context with a 5-minute timeout
timedCtx, cancel := dbos.WithTimeout(ctx, 5*time.Minute)
defer cancel()

handle, err := dbos.RunWorkflow(timedCtx, processTask, "data")
if err != nil {
	log.Fatal(err)
}

Key timeout behaviors:

  • Timeouts are start-to-completion: the timeout begins when the workflow starts execution, not when it's enqueued
  • Timeouts are durable: they persist across restarts, so workflows can have very long timeouts (hours, days, weeks)
  • Cancellation happens at the beginning of the next step - the current step completes first
  • Cancelling a workflow also cancels all child workflows

Reference: Workflow Timeouts