fix: remove orphaned duplicate balanceInterval in agent.mts - #26
Open
osr21 wants to merge 1 commit into
Open
Conversation
startPaymentLoop() already assigns balanceInterval right after this line runs (it is called unconditionally at the bottom of the file, and again after every spending-limit pause/resume cycle). Setting it here too means the handle from this first setInterval is immediately overwritten and can never be cleared -- it keeps firing every 30s for the life of the process, so checkAndRedeposit ends up running twice as often as the comments state.
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
Removes a duplicate/orphaned
balanceIntervalinagent.mts.Bug
At startup,
balanceIntervalis assigned once right after the initialdeposit (
balanceInterval = setInterval(checkAndRedeposit, 30_000);), andthen
startPaymentLoop()is called immediately after, which assignsbalanceIntervalagain to a new interval. The first interval's handle isoverwritten before it's ever cleared, so it keeps running for the lifetime of
the process with no way to cancel it.
Net effect:
checkAndRedepositactually runs on two overlapping 30sschedules instead of one (contradicting the comment above it), and one
setIntervalhandle leaks for the life of the CLI process.Fix
Removed the premature top-level assignment.
startPaymentLoop()alreadysets up
balanceInterval(and is the single place that creates/clears itacross pause/resume cycles triggered by
handleLimitReached()), so nothingelse needs to schedule it beforehand.
Testing
Read-through / static verification — traced every assignment and
clearIntervalcall site forbalanceIntervalinagent.mtsto confirmstartPaymentLoop()is the only place that should own it, and that this wasthe sole leaked reference. No functional change to the deposit/payment logic
itself, only the interval bookkeeping.