Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions codex-rs/async-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ where
mod tests {
use super::*;
use pretty_assertions::assert_eq;
use std::future::pending;
use std::time::Duration;
use tokio::task;
use tokio::time::sleep;
Expand All @@ -58,12 +59,7 @@ mod tests {
token_clone.cancel();
});

let result = async {
sleep(Duration::from_millis(100)).await;
7
}
.or_cancel(&token)
.await;
let result = pending::<i32>().or_cancel(&token).await;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound await to prevent indefinite test hangs

Using pending::<i32>() makes this test rely entirely on cancellation to complete; if or_cancel ever regresses and does not wake on token.cancelled(), the await never resolves and cargo test can hang instead of failing with a clear assertion. The previous bounded future would fail fast in that scenario, so this change weakens failure signaling and can stall CI/debugging; wrapping the await in a timeout preserves determinism without risking an unbounded hang.

Useful? React with 👍 / 👎.


cancel_handle.await.expect("cancel task panicked");
assert_eq!(Err(CancelErr::Cancelled), result);
Expand Down
Loading