Timeout
No answer came before the call's deadline, and the call may still run or may have run already.
Timeout means the call’s deadline passed before an answer came back. The status is 504.
Issue
A call fails with Timeout and the message the call's deadline passed. In a luna, the LunaCallError has retryable: true.
The client in luna/client also throws a ConnectionError with the code Timeout when it gives up waiting itself. Its messages are the call took too long; it may still happen and could not connect in time.
Cause
Every call has a deadline. A call from outside, or with ctx.call, waits 60 seconds unless the caller sets another deadline. The client in luna/client waits 30 seconds by default, connecting included.
The deadline passes while the handler runs or waits its turn. A handler that awaits a slow call or a slow fetch uses up its caller’s time.
Timeout differs from OutcomeUnknown in what stopped. With Timeout the caller stopped waiting, and the luna may still be running the call. With OutcomeUnknown the luna itself stopped.
Solution
A query is safe to retry. A write may still finish after the timeout, so retry it only with an idempotency key.
Set the deadline that fits the work, from each place a call starts:
| Caller | Set it with |
|---|---|
| HTTP | The luna-timeout-ms header, in milliseconds |
| A luna | timeout in the options of ctx.call, such as "10s" |
| An app | callTimeoutMs in createClient, or timeoutMs on one call |
Work that takes longer than a call should wait for belongs in the background. Answer at once and continue with ctx.send or a durable run, as Run durable work shows.