fix: prevent overlapping poll cycles in managers

Guarding polling re-entry avoids stacked async polls under slow responses, and unref on pending-call cleanup timer reduces idle wakeups.
This commit is contained in:
YeonGyu-Kim
2026-02-17 03:06:40 +09:00
parent 14374095af
commit 3e06d280a9
6 changed files with 169 additions and 6 deletions
+7
View File
@@ -80,6 +80,7 @@ export class BackgroundManager {
private client: OpencodeClient
private directory: string
private pollingInterval?: ReturnType<typeof setInterval>
private pollingInFlight = false
private concurrencyManager: ConcurrencyManager
private shutdownTriggered = false
private config?: BackgroundTaskConfig
@@ -1546,6 +1547,9 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
}
private async pollRunningTasks(): Promise<void> {
if (this.pollingInFlight) return
this.pollingInFlight = true
try {
this.pruneStaleTasksAndNotifications()
const statusResult = await this.client.session.status()
@@ -1601,6 +1605,9 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
if (!this.hasRunningTasks()) {
this.stopPolling()
}
} finally {
this.pollingInFlight = false
}
}
/**