From 5023a99f91bf3f37a87b2e6a9e1418812e3ab465 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Mon, 2 Mar 2026 21:21:47 +0100 Subject: [PATCH] Fix circuit breaker triggering from parallel download failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Debounce: simultaneous failures within 2s count as 1 failure (prevents 8 parallel unrestrict failures from instant-triggering) - Raise threshold from 8 to 20 consecutive failures before cooldown - Escalation tiers: 20→30s, 35→60s, 50→120s, 80+→300s Co-Authored-By: Claude Opus 4.6 --- package.json | 2 +- src/main/download-manager.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index da8102c..a1295cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "real-debrid-downloader", - "version": "1.5.22", + "version": "1.5.23", "description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)", "main": "build/main/main/main.js", "author": "Sucukdeluxe", diff --git a/src/main/download-manager.ts b/src/main/download-manager.ts index 12d3c7a..dae52aa 100644 --- a/src/main/download-manager.ts +++ b/src/main/download-manager.ts @@ -3051,11 +3051,18 @@ export class DownloadManager extends EventEmitter { if (entry.lastFailAt > 0 && now - entry.lastFailAt > 120000) { entry.count = 0; } + // Debounce: simultaneous failures (within 2s) count as one failure + // This prevents 8 parallel downloads failing at once from immediately hitting the threshold + if (entry.lastFailAt > 0 && now - entry.lastFailAt < 2000) { + entry.lastFailAt = now; + this.providerFailures.set(provider, entry); + return; + } entry.count += 1; entry.lastFailAt = now; - // Escalating cooldown: 8 failures→30s, 15→60s, 25→120s, 40+→300s - if (entry.count >= 8) { - const tier = entry.count >= 40 ? 3 : entry.count >= 25 ? 2 : entry.count >= 15 ? 1 : 0; + // Escalating cooldown: 20 failures→30s, 35→60s, 50→120s, 80+→300s + if (entry.count >= 20) { + const tier = entry.count >= 80 ? 3 : entry.count >= 50 ? 2 : entry.count >= 35 ? 1 : 0; const cooldownMs = [30000, 60000, 120000, 300000][tier]; entry.cooldownUntil = now + cooldownMs; logger.warn(`Provider Circuit-Breaker: ${provider} ${entry.count} konsekutive Fehler, Cooldown ${cooldownMs / 1000}s`);