Use this when automation steps can hang and need timeouts that fail cleanly.
Timeout · Error Handling
Timeouts in error handling stop operations that hang, such as a stuck API call or SSH session, and turn them into clear failures that can be retried or reported.
1. Timeouts prevent hangs.
2. Set connect/read and overall timeouts.
3. Base values on measurements.
4. Clean up on timeout.
5. Report clearly.
operation → timeout → abort/cleanup
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as ambiguous target identity, stale inputs, partial success, unsafe retry, permission drift and confusing tool completion with target-evidence of the actual state, choosing the cases most relevant to timeout scope, cancellation semantics, underlying work that may continue after client timeout and mandatory state read-before-retry.
Step 2 Common mistakes Narrow the fault
- One global timeout for steps with very different durations.
Step 3 Where it fails Narrow the fault
Timeout or connection loss is especially ambiguous because work may continue after the client stops waiting.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Set timeouts on network calls and waits.
- Base them on measured durations.
- Fail clearly when they expire.
timeout 60 <cmd>— command timeout- Client timeouts (connect/read) — network calls
- Overall job timeout — runaway protection
ReferenceWhy it matters1 section · depth on demand
In depth
A timeout limits how long an operation may take before it is abandoned. Without timeouts, one unresponsive device or API can hang an entire automation run indefinitely, holding locks and blocking schedules. With timeouts set too short, slow but healthy operations fail.
Layers of timeouts:
| Level | Example |
|---|---|
| Connection | TCP/SSH connect: 5–15 s |
| Operation | Single command/API call: seconds to minutes |
| Step | Image copy: tens of minutes |
| Whole job | Upper bound for the run |
Set each from measured normal durations with a margin, and log how long operations take so timeouts can be tuned.
requests.get(url, timeout=(5, 30)) # connect, read
timeout 300 ./backup.sh || echo "backup exceeded 5 minutes"
- command: /usr/local/bin/sync
async: 1800
poll: 30
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
The linked authority for bounded mechanics is Microsoft Azure Architecture Center — Retry pattern; documentation support is separate from observed lab/production Evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Error Handling > Timeout. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/architecture/patterns/retry · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For timeout scope, cancellation semantics, underlying work that may continue after client timeout and mandatory state read-before-retry, prefer typed fields and stable IDs over human presentation text.