Skip to content

[repo-monitor] High: Polling timeout not enforced when poll_interval > max_wait #2

@Liohtml

Description

@Liohtml

Summary

The wait_for_status polling loop checks elapsed time at the top, then sleeps for poll_interval. If poll_interval > max_wait, the timeout is never enforced and the function blocks for the full sleep duration.

Location

  • File: src/lib.rs
  • Line(s): 236–270

Severity

High

Details

loop {
    if started.elapsed() > self.client.max_wait {
        return Err(Error::Timeout(...));
    }
    tokio::time::sleep(self.client.poll_interval).await; // sleep happens AFTER the check
    // ...
}

With max_wait=10s and poll_interval=60s, the elapsed check passes (t≈0 < 10s), then sleeps 60s — the timeout is never enforced.

Suggested Fix

Clamp the sleep duration to the remaining time:

let remaining = self.client.max_wait
    .checked_sub(started.elapsed())
    .ok_or(Error::Timeout(self.client.max_wait))?;
tokio::time::sleep(remaining.min(self.client.poll_interval)).await;

Automated finding by repo-monitor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions