Wait for requested delay in rate limit errors (#2266)

Fixes: https://github.com/openai/codex/issues/2131

Response doesn't have the delay in a separate field (yet) so parse the
message.
This commit is contained in:
pakrym-oai
2025-08-13 15:43:54 -07:00
committed by GitHub
parent 37fc4185ef
commit 41eb59a07d
5 changed files with 152 additions and 22 deletions

View File

@@ -213,7 +213,9 @@ async fn process_chat_sse<S>(
let sse = match timeout(idle_timeout, stream.next()).await {
Ok(Some(Ok(ev))) => ev,
Ok(Some(Err(e))) => {
let _ = tx_event.send(Err(CodexErr::Stream(e.to_string()))).await;
let _ = tx_event
.send(Err(CodexErr::Stream(e.to_string(), None)))
.await;
return;
}
Ok(None) => {
@@ -228,7 +230,10 @@ async fn process_chat_sse<S>(
}
Err(_) => {
let _ = tx_event
.send(Err(CodexErr::Stream("idle timeout waiting for SSE".into())))
.send(Err(CodexErr::Stream(
"idle timeout waiting for SSE".into(),
None,
)))
.await;
return;
}