Skip to content

Commit 29f86cd

Browse files
fix(pricing): wait for first cache test request
Use the five-second accept timeout for the first request in the zero-loaded Models.dev cache regression server, then use the 250 ms idle timeout only for optional tail requests. This prevents busy runners from missing the initial 200 response while preserving the existing 200 -> 304 -> 200 ETag/cache coverage. Co-authored-by: wishworldbetter <[email protected]>
1 parent 3ab4fd3 commit 29f86cd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎rust/crates/ccusage/src/http.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,15 @@ mod tests {
371371
);
372372
let handle = thread::spawn(move || {
373373
let mut requests = Vec::new();
374-
for response in responses {
375-
let Some(mut stream) = accept_until_idle(&listener, Duration::from_millis(250))?
376-
else {
377-
break;
374+
for (response_index, response) in responses.into_iter().enumerate() {
375+
let mut stream = if response_index == 0 {
376+
accept_with_timeout(&listener)?
377+
} else {
378+
let Some(stream) = accept_until_idle(&listener, Duration::from_millis(250))?
379+
else {
380+
break;
381+
};
382+
stream
378383
};
379384
requests.push(read_request(&mut stream)?);
380385
stream.write_all(response.as_bytes())?;

0 commit comments

Comments
 (0)