Handle large WeebCentral catalogs and correct MangaPill checkpoint monitoring

This commit is contained in:
Codex committed 2026-10-14 14:01:05 +02:00
1 parent 0d51f214d5
commit edbc9c6056
11 files changed
+102 -7

No files matched your search

+3
View File
@@ -36,6 +36,9 @@ class Monitor {
const ids = new Set();
for (const entry of scraper.active || []) {
const id = entry.current.id; ids.add(id);
// Without a checkpoint, a null progress key stays constant forever and
// cannot prove a stall. Do not quarantine a live worker on that basis.
if (!entry.job) { this.observations.delete(id); this.resolve(`stall:${id}`); continue; }
const key = progressKey(entry.job), prior = this.observations.get(id);
if (!prior || prior.key !== key) { this.observations.set(id, { key, at: now }); this.resolve(`stall:${id}`); continue; }
if (scraper.paused || scraper.sourcePaused?.[entry.source]) continue;
+12
View File
@@ -24,3 +24,15 @@ test('Sentinel reports service failures without restart loops and resolves recov
await monitor.observe({ ok: true }, { active: [], queue: [], paused: false });
assert.equal(monitor.state.status, 'healthy'); assert.ok(monitor.incidents.every(i => i.state === 'resolved'));
});
test('missing checkpoint does not trigger a false stall recovery', async () => {
let now = 0, recoveries = 0;
const monitor = new Monitor({ now: () => now, stallMs: 100 });
const state = { paused: false, active: [{ source: 'mangapill', current: { id: 'job', title: 'Manga' }, job: null }], queue: [] };
for (const advance of [0, 1000000, 2000000]) {
now = advance;
await monitor.observe({ ok: true }, state, async () => { recoveries++; return { changed: true }; });
}
assert.equal(recoveries, 0);
assert.equal(monitor.incidents.some(item => item.key === 'stall:job'), false);
});