[PR #2720] [MERGED] fix(process): report no remaining time after a provider deadline fires #5343

Closed
opened 2026-10-31 01:05:53 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2720
Author: @kaoru0822-kitauji
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/provider-deadline-expired-remaining


📝 Commits (4)

  • dfdaa0c fix(process): report no remaining time after a provider deadline fires
  • fe8f35a Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining
  • 3d372ef Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining
  • ca533f7 Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining

📊 Changes

2 files changed (+20 additions, -0 deletions)

View changed files

📝 src/process/ProviderDeadline.test.ts (+17 -0)
📝 src/process/ProviderDeadline.ts (+3 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2720 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/provider-deadline-expired-remaining` --- ### 📝 Commits (4) - [`dfdaa0c`](https://github.com/morluto/rea/commit/dfdaa0ca74cc84a45dcb186422a0f51aa61bc427) fix(process): report no remaining time after a provider deadline fires - [`fe8f35a`](https://github.com/morluto/rea/commit/fe8f35a4a1e055f72256ff9e76934ce272bfc7a9) Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining - [`3d372ef`](https://github.com/morluto/rea/commit/3d372efcc4d1b5cb85b2fc97b9d22b6e9d2d3d3a) Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining - [`ca533f7`](https://github.com/morluto/rea/commit/ca533f7e0d8b43b41cb1297a8aa71c3a161ff211) Merge remote-tracking branch 'origin/main' into fix/provider-deadline-expired-remaining ### 📊 Changes **2 files changed** (+20 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/process/ProviderDeadline.test.ts` (+17 -0) 📝 `src/process/ProviderDeadline.ts` (+3 -0) </details> ### 📄 Description ## 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:05:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5343
No description provided.