fix(anthropic-recovery): fix retry timer memory leak in context window recovery

🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-03-31 17:33:24 -07:00
parent 990095d22e
commit 116b1f9e4e
6 changed files with 85 additions and 12 deletions
@@ -28,6 +28,11 @@ export function clearSessionState(
autoCompactState: AutoCompactState,
sessionID: string,
): void {
const retryTimer = autoCompactState.retryTimerBySession.get(sessionID)
if (retryTimer !== undefined) {
clearTimeout(retryTimer)
autoCompactState.retryTimerBySession.delete(sessionID)
}
autoCompactState.pendingCompact.delete(sessionID)
autoCompactState.errorDataBySession.delete(sessionID)
autoCompactState.retryStateBySession.delete(sessionID)
@@ -36,6 +41,26 @@ export function clearSessionState(
autoCompactState.compactionInProgress.delete(sessionID)
}
export function setRetryTimer(
autoCompactState: AutoCompactState,
sessionID: string,
timeout: ReturnType<typeof setTimeout>,
): void {
const existingTimer = autoCompactState.retryTimerBySession.get(sessionID)
if (existingTimer !== undefined) {
clearTimeout(existingTimer)
}
autoCompactState.retryTimerBySession.set(sessionID, timeout)
}
export function clearRetryTimer(autoCompactState: AutoCompactState, sessionID: string): void {
const retryTimer = autoCompactState.retryTimerBySession.get(sessionID)
if (retryTimer !== undefined) {
clearTimeout(retryTimer)
autoCompactState.retryTimerBySession.delete(sessionID)
}
}
export function getEmptyContentAttempt(
autoCompactState: AutoCompactState,
sessionID: string,