Skip to content

Fix keepalive readiness deadlock when sub-millisecond time remains - #1004

Draft
fafhrd91 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-failing-github-actions-job
Draft

Fix keepalive readiness deadlock when sub-millisecond time remains#1004
fafhrd91 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The macOS CI job timed out because ntex-util services::keepalive::tests::test_ka hung indefinitely (SLOW [>420.000s] until the 10-minute step timeout).

KeepAliveService::ready() re-arms its Sleep with the time remaining until expiration, truncated to whole milliseconds. now() is a low-resolution (5ms) clock, so the remainder is frequently sub-millisecond, producing Sleep::reset(Millis(0)). TimerHandle::update_timer treats 0 as "clear the timer", leaving the sleep permanently elapsed — the subsequent poll_elapsed returns Ready and registers no waker, so the dispatcher parks forever and readiness never resolves.

Changes

  • ntex-util/src/services/keepalive.rs
    • Re-arm the sleep with a minimum of Millis(1) so a waker is always registered.
    • Replace the single re-poll with a loop, so ready() only returns Ok once the timer is actually pending (or Err if the keep-alive expired in the meantime).
    • Add test_ka_sub_millis, which forces the sub-millisecond state and asserts the timer is re-armed after ready().
let expire = expire - now;

// sleep must be reset to non zero duration,
// otherwise it stays in elapsed state and waker
// never gets registered
let expire: u32 = expire.as_millis().try_into().unwrap_or(u32::MAX);
self.sleep.reset(Millis(expire.max(1)));

…xpiration

Co-authored-by: fafhrd91 <598990+fafhrd91@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix the failing GitHub Actions job stable - aarch64-apple-darwin Fix keepalive readiness deadlock when sub-millisecond time remains Sep 1, 2026
Copilot AI requested a review from fafhrd91 September 1, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants