⚡️ perf: improve extraction status, stuck detection, and retry logic
Build and Release / build (push) Has been cancelled
Build and Release / build (push) Has been cancelled
- Extraction status: "Entpackt - Done" / "Entpacken - Ausstehend" - Per-item extraction progress (no cross-contamination) - Validating-stuck watchdog: abort items stuck >45s in "Link wird umgewandelt" - Global stall timeout reduced 90s → 60s, unrestrict timeout 120s → 60s - Unrestrict retry: longer backoff (5/10/15s), reset partial downloads - Stall retry: reset partial downloads for fresh link - Mega-Web generate: max 30 polls (was 60), 45s overall timeout - Mega-Web session refresh: 10min (was 20min) - Comprehensive logging on all retry/failure paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
0e55c28142
commit
1825e8ba04
@@ -196,7 +196,7 @@ export class MegaWebFallback {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.cookie || Date.now() - this.cookieSetAt > 20 * 60 * 1000) {
|
||||
if (!this.cookie || Date.now() - this.cookieSetAt > 10 * 60 * 1000) {
|
||||
await this.login(creds.login, creds.password, signal);
|
||||
}
|
||||
|
||||
@@ -278,6 +278,8 @@ export class MegaWebFallback {
|
||||
|
||||
private async generate(link: string, signal?: AbortSignal): Promise<{ directUrl: string; fileName: string } | null> {
|
||||
throwIfAborted(signal);
|
||||
// Overall timeout for the entire generate operation (45s)
|
||||
const generateSignal = withTimeoutSignal(signal, 45000);
|
||||
const page = await fetch(DEBRID_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -291,7 +293,7 @@ export class MegaWebFallback {
|
||||
password: "",
|
||||
showLinks: "1"
|
||||
}),
|
||||
signal: withTimeoutSignal(signal, 30000)
|
||||
signal: withTimeoutSignal(generateSignal, 20000)
|
||||
});
|
||||
|
||||
const html = await page.text();
|
||||
@@ -300,8 +302,10 @@ export class MegaWebFallback {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let attempt = 1; attempt <= 60; attempt += 1) {
|
||||
throwIfAborted(signal);
|
||||
let reloadCount = 0;
|
||||
let hosterRetryCount = 0;
|
||||
for (let attempt = 1; attempt <= 30; attempt += 1) {
|
||||
throwIfAborted(generateSignal);
|
||||
const res = await fetch(DEBRID_AJAX_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -314,12 +318,14 @@ export class MegaWebFallback {
|
||||
code,
|
||||
autodl: "0"
|
||||
}),
|
||||
signal: withTimeoutSignal(signal, 15000)
|
||||
signal: withTimeoutSignal(generateSignal, 12000)
|
||||
});
|
||||
|
||||
const text = (await res.text()).trim();
|
||||
if (text === "reload") {
|
||||
await sleepWithSignal(650, signal);
|
||||
reloadCount += 1;
|
||||
// Back off progressively: 500ms, 700ms, 900ms...
|
||||
await sleepWithSignal(Math.min(2000, 500 + reloadCount * 200), generateSignal);
|
||||
continue;
|
||||
}
|
||||
if (text === "false") {
|
||||
@@ -333,7 +339,11 @@ export class MegaWebFallback {
|
||||
|
||||
if (!parsed.link) {
|
||||
if (/hoster does not respond correctly|could not be done for this moment/i.test(parsed.text || "")) {
|
||||
await sleepWithSignal(1200, signal);
|
||||
hosterRetryCount += 1;
|
||||
if (hosterRetryCount > 5) {
|
||||
return null;
|
||||
}
|
||||
await sleepWithSignal(Math.min(3000, 800 + hosterRetryCount * 400), generateSignal);
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user