Skip to content

fix(process): report no remaining time after a provider deadline fires - #2720

Merged
kaoru0822-kitauji merged 4 commits into
mainfrom
fix/provider-deadline-expired-remaining
Oct 13, 2026
Merged

kaoru0822-kitauji merged 4 commits into
mainfrom
fix/provider-deadline-expired-remaining

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Problem

src/process/ProviderDeadline.test.ts > aborts a bounded wait when its real monotonic deadline expires fails intermittently in CI. I saw it on two separate runs of #2683 and #2690 today:

AssertionError: expected 1 to be +0
  expect(deadline.remainingMs()).toBe(0);

Root cause

This is an inconsistency in ProviderStartupDeadline, not in the test. Node timers run on libuv's millisecond loop clock and can fire while performance.now() is still a fraction of a millisecond short of #deadlineAt. The timer callback then sets interruption = "timeout" and aborts the signal, but remainingMs() computes Math.ceil(deadlineAt - performance.now()) = ceil(0.4) = 1. Consumers see an expired, aborted deadline that still reports time left. For example, while (deadline.remainingMs() > 0) polling in HopperClient and GhidraSocketConnection can keep going past the deadline.

Fix

remainingMs() returns 0 once the deadline's own timer has classified a timeout. Behaviour before the deadline fires, and after caller cancellation, is unchanged.

Validation

  • New deterministic test: fake setTimeout, with performance.now() mocked 0.4 ms short of the deadline when the timer fires. It fails on main (remainingMs() is 1) and passes with the fix.
  • ProviderDeadline.test.ts passed 6 of 6 repeated local runs. npm run test:focused on the 4 test files using ProviderStartupDeadline (Hopper/Ghidra/native module consumers): 91 passed.
  • npm run check:fast passes.

🤖 Generated with Claude Code

Node timers can fire while performance.now() is still a fraction of a
millisecond short of the monotonic deadline. ProviderStartupDeadline then
reported interruption "timeout" and an aborted signal while remainingMs()
returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0
(Hopper and Ghidra startup) could run past an elapsed deadline, and the
real-timer test "aborts a bounded wait when its real monotonic deadline
expires" failed intermittently in CI (expected 1 to be 0).

Once the deadline's own timer has classified a timeout, report zero
remaining time. A deterministic regression test fires the timer with the
monotonic clock 0.4 ms short of the deadline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T11:51:28.004674Z ca533f7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

ProviderStartupDeadline.remainingMs() now returns zero after a timeout has been recorded, even when the timer fires just before the monotonic clock reaches the deadline.

  • A fired provider deadline now reports no time remaining.

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants