fix(anthropic-recovery): fix retry timer memory leak in context window recovery
🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user