all docs
/ troubleshooting

Stream ends with a gateway_timeout error event

A stream silent past ACE_STREAM_IDLE_S (300 s) or open past ACE_STREAM_DEADLINE_S (3600 s) is closed with one terminal error event.

Symptom

A streamed response stops with a final error event carrying "type": "gateway_timeout" after the status line was already 200.

Cause

Once a stream's status line has left, no header can change, so the deadline is reported in-band: a stream silent for ACE_STREAM_IDLE_S (default 300 s) or open past ACE_STREAM_DEADLINE_S (default 3600 s) is closed with that event. Before the response starts, the same deadline is a 504 gateway_timeout.

Fix

Handle the terminal error event in your stream reader as a failed turn. On a non-streamed 504 gateway_timeout nothing had been sent, so a retry is safe; x-ace-stage-durations names the stage that was still running.

Source