mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-25 12:00:02 +08:00
The handler keeps one idle timer, armed for the oldest open project a
trim can release, and it skips a project whose catch-up is still
running. scheduleIdleRelease returned early while a timer was armed.
So when a project's catch-up settled after a newer project had armed
the timer, the trim found the older project not yet idle and kept the
newer one's deadline. The older project stayed open, writer lock
included, until then: up to nearly twice the idle timeout. With the
10-minute default, a project last used at 0:00 whose catch-up settles
at 9:50, while another was used at 8:20, went at 18:20, not 10:00.
Each trim that gets as far as scheduling now replaces the timer,
re-armed for the oldest releasable project. Trims skip scheduling
while calls are in flight, and the last call to finish trims again, so
a settled catch-up still gets its own deadline. There is still one
timer and no polling.
Validation: the new fake-timer test drives that order through
execute(). On main a565f215 nothing is released at 3.6 s (expected []
to deeply equal [ 'a' ]); with the fix A goes at 3.5 s and B at 4.5 s.
Its afterEach restores both CODEGRAPH_* variables the test sets, also
when the test fails: checked with the test failing on main's code,
with the variables preset and with them unset.
Follow-up to issue 2087, whose idle release (PR #2283) shipped in 1.6.2.
Original PR #2306 by @bompus.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>