Flow Studio
Error Handling & Circuit Breaker
How service errors surface as node error ports, retry configuration, and the circuit breaker pattern that protects the platform from cascading failures.
Error Port Routing
Non-2xx responses from a business service route to the error port by default. The error output contains:
{
"statusCode": 503,
"errorCode": "SERVICE_UNAVAILABLE",
"message": "Payroll service is temporarily unavailable",
"serviceId": "payroll-service",
"operationId": "calculatePayslip",
"retryAfterSeconds": 30
}
Status Code Port Mapping
Configure specific status codes to route to named ports instead of the generic error port:
{
"statusCodePorts": {
"404": "notFound",
"409": "conflict",
"422": "validationError",
"503": "serviceDown"
}
}
This allows the workflow to handle different error scenarios with specific recovery paths rather than a single error handler.
Circuit Breaker
The circuit breaker prevents cascading failures when a service is down. It operates in three states:
| State | Behavior | Transition |
|---|---|---|
| Closed | Calls pass through normally | → Open after N consecutive failures |
| Open | Calls fail immediately without hitting the service | → Half-Open after timeout (default 30s) |
| Half-Open | One probe call allowed through | → Closed (success) or Open (failure) |
// Circuit breaker config per service
new CircuitBreakerPolicy
{
FailureThreshold = 5, // 5 consecutive failures → Open
SamplingDurationSeconds = 60,
OpenDurationSeconds = 30,
SuccessThresholdInHalfOpen = 1
}
Circuit breaker fires error port. When the circuit is Open, the node immediately routes to the error port with
errorCode: "CIRCUIT_OPEN". Connect an error port edge that either retries later (via a WaitNode + SubWorkflow) or provides a graceful degraded response.