stream_error
The message text is shown in the example below.
| HTTP status | 502 |
type | api_error |
| Retry? | Yes, with back-off |
| Status | In the public catalog (error-envelope.ts) |
| Extra fields | none |
When it happens
A streamed response started with 200 OK and then broke. The last event carries this envelope with type: api_error.
Example
{
"error": {
"type": "api_error",
"code": "stream_error",
"message": "The response stream was interrupted. Retry the request.",
"param": null,
"request_id": "req_6f1c2a9e0b7d4c3a8e5f1b2d"
}
}How to fix it
- Discard the partial text, or keep it only for display, and retry the whole request.
- Do not try to resume from the middle; a new request is a new generation.
Detect it in code
err = resp.json().get("error", {})
if resp.status_code == 502 and err.get("code") == "stream_error":
delay = err.get("retry_after") or 2
time.sleep(delay) # then retryRelated
Was this page helpful?