-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
run_with_progress can livelock when the broadcast progress channel is closed.
Affected code
src/progress.rs(run_with_progress)
Root cause
run_with_progress uses:
tokio::select! { biased; ... }- one branch awaiting
progress_rx.recv() - one branch awaiting the main future
When the sender side drops, progress_rx.recv() returns Err(Closed) immediately and keeps being ready forever. With biased;, that branch is always preferred, and because closed errors are ignored, the loop can spin and starve completion.
Impact
- Potential hang during interactive startup/context switch operations using
run_with_progress. - Potential CPU spin in closed-channel edge cases.
Proposed fix
- Handle recv errors explicitly:
Err(RecvError::Closed): disable progress polling (or break) and await the main future directly.Err(RecvError::Lagged(_)): continue.
- Optionally remove
biased;to reduce starvation risk, but explicit Closed handling is still required.
Tests to add
- Closed receiver + pending future: function should still return when future completes (no hang).
- Lagged updates do not abort operation.
- Regression test with timeout to guard against infinite loop.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels