
Timeout Propagation: Why Your Deadlines Need to Flow Through the Entire Call Chain
Timeout Propagation: Why Your Deadlines Need to Flow Through the Entire Call Chain Ignoring a timeout on an API call doesn't isolate the failure; it poisons the shared thread pool and starves concurrent requests. What We're Building We are implementing a deadline-aware client in a Go microservice. Our goal is to ensure that when a service receives a request, it knows exactly how much time remains for the entire transaction, not just the current function. This involves calculating the time budget before entering the call chain and passing it explicitly to every downstream dependency. Step 1 — Establish the Transaction Deadline Every handler must declare the maximum time allowed for the whole request lifecycle. This prevents downstream services from running indefinitely if the parent service is overwhelmed. const maxTransactionTime = 5 * time . Second func handler ( req interface {}) error { ctx , cancel := context . WithTimeout ( context . Background (), maxTransactionTime ) defer cance
Continue reading on Dev.to
Opens in a new tab



