Commit c5de4e0
fix: prevent infinite SSE error loop and remove aggressive read_timeout (#453)
* fix: prevent infinite SSE error loop and remove aggressive read_timeout
Two bugs caused ~20% of concurrent streaming requests through the gateway
to produce infinite `data: error: Failed to perform completion: error
decoding response body` lines (multi-GB responses of repeated errors):
1. SSE parser never terminated after a byte-stream error - it kept
polling the broken reqwest stream, which kept returning errors.
Added a `finished` flag to BufferedSSEParser that stops polling
after the first error or stream end.
2. The vLLM HTTP client set `read_timeout` (default 30s) which applies
to every individual chunk read. Under concurrent load, inter-chunk
gaps can exceed this, causing spurious timeouts. Removed it to match
the pattern used by external providers (Anthropic, OpenAI, Gemini)
which only set connect_timeout and pool_idle_timeout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add per-request timeouts to non-streaming vLLM methods
After removing the client-level read_timeout, the non-streaming methods
(get_signature, get_attestation_report, models, chat_completion) were
left without timeout protection. Add explicit per-request .timeout()
using config.timeout_seconds to prevent hanging connections and resource
exhaustion.
Streaming methods (chat_completion_stream, text_completion_stream)
intentionally omit per-request timeout since reqwest's .timeout() covers
the entire request lifecycle including body streaming, which would kill
long-running SSE streams.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add TTFB timeout to streaming methods and fix cargo fmt
Add per-request `.timeout()` to `chat_completion_stream` and
`text_completion_stream` to protect against backends that accept
connections but never respond. In reqwest, the per-request timeout
covers connection + response headers; the body stream is consumed
lazily after `.send()` resolves, so this does not reintroduce the
per-chunk timeout issue.
Also fix cargo fmt formatting in the SSE parser test.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 73db980 commit c5de4e0
2 files changed
+79
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
138 | 149 | | |
139 | 150 | | |
140 | 151 | | |
| |||
158 | 169 | | |
159 | 170 | | |
160 | 171 | | |
| 172 | + | |
| 173 | + | |
161 | 174 | | |
162 | 175 | | |
163 | 176 | | |
| 177 | + | |
164 | 178 | | |
165 | 179 | | |
166 | 180 | | |
| |||
383 | 397 | | |
384 | 398 | | |
385 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
386 | 459 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
| |||
151 | 148 | | |
152 | 149 | | |
153 | 150 | | |
| 151 | + | |
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
| |||
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
| 199 | + | |
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
| |||
237 | 236 | | |
238 | 237 | | |
239 | 238 | | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
| |||
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| 340 | + | |
339 | 341 | | |
340 | 342 | | |
341 | 343 | | |
| |||
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
| 401 | + | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
| |||
0 commit comments