A timeout limits how long a process waits for a response. When the response does not arrive in time, the waiting operation raises an error instead of blocking indefinitely. section 7.3.3 section 6.2.3
Use timeouts to control responsiveness, while accounting for what happens to the underlying request:
- GenServer.call/2 waits up to five seconds by default; GenServer.call/3 accepts a timeout in milliseconds. section 6.2.3
- Task.await/1 also defaults to five seconds, while Task.await/2 accepts a different timeout. section 10.1.1
- A timed-out call stops waiting but does not remove the request from the receiver's mailbox; the receiver may process it later. section 7.3.3
- Shorter limits can improve responsiveness, but overloaded servers may still accumulate messages and consume memory. section 7.3.3
Waiting for concurrent work
Start independent queries with Task.async/1, then collect their results with Enum.map(tasks, &Task.await/1). Five simulated two-second queries complete together in about two seconds, subject to the await timeout. section 10.1.1








