fix(act): self-re-arm DeferTimer on a premature ceiling clamp (ACT-1288) - #1290
Merged
Conversation
DeferTimer.schedule clamps a wait to the 32-bit setTimeout ceiling (~24.8 days) and its comment promised on_wake re-schedules for the remaining span, but the drain consumer's on_wake only sets its armed flag and its arm- triggered drain early-returns before the re-schedule (the stream is still store-excluded). So a defer/autoclose-cooldown past the ceiling fired once prematurely, then never re-armed — the precise wake was lost and the entry leaked in the parked set. Self-re-arm inside the fire callback, but only on a premature ceiling clamp (nothing came due, yet entries remain). A normal wake still leaves re-arming to the consumer, preserving the fire-once-per-schedule model (and the existing "rescheduling cancels the prior timer" test). The existing far-future test asserted only the first ceiling wake; extend it to advance past the real due-time and prove the re-arm fires and GCs the entry (red without the fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🎉 This PR is included in version @rotorsoft/act-v1.23.10 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @rotorsoft/act-tck-v1.27.13 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1288.
DeferTimer.schedule()clamps a wait to the 32-bitsetTimeoutceiling (~24.8 days) and its comment promisedon_wakere-schedules for the remaining span — but the drain consumer'son_wakeonly sets_armed, and its arm-triggered drain early-returns before the:538re-schedule (the stream is still store-excluded bydeferred_at). So a defer / autoclose cooldown past the ceiling (after: { days: 90 }) fired once prematurely, then never re-armed: the precise wake was lost and the entry leaked in the parked set.Fix
Self-re-arm inside the fire callback, but only on a premature ceiling clamp — detected as "nothing came due, yet entries remain" (the earliest due-time was past the ceiling, so the wake fired early and GC'd nothing). A normal wake (something came due) still leaves re-arming to the consumer, preserving the fire-once-per-schedule model and the existing
"rescheduling cancels the prior timer"test.Proof (red-first)
The existing
"clamps a far-future due-time … and re-arms"test only asserted the first ceiling wake — which is why the bug shipped. Extended it to advance past the real due-time and assert the timer fires again (through the intermediate ceiling clamps) and finally GCs the entry:Scope
Internal (
defer-timer.ts); no public surface. All defer + autoclose suites green; 100% coverage.Gates
Typecheck ✅ · tests ✅ (3125 passed) · 100% coverage ✅ · lint ✅ · build ✅.
rfc-gate: exempt — no new public surface. The stability-snapshot delta is the internal
defer-timer.tsfire-callback source text (an@internalmodule); the exported surface is unchanged.Closes #1288
🤖 Generated with Claude Code