fix(live): prevent analysis crash on large catalogs (#26)
Bound synchronous live channel enrichment and tolerate minimal projection payloads so analysis and listings do not blank the UI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -289,3 +289,37 @@ test('search and language filters run before expensive standard and EPG enrichme
|
||||
assert.equal(standardCalls, 1);
|
||||
assert.equal(epgCalls, 1);
|
||||
});
|
||||
|
||||
test('full catalog listing skips synchronous per-channel enrichment', () => {
|
||||
const db = createProjectionDb();
|
||||
for (let index = 0; index < 500; index++) {
|
||||
seedProjectionChannel(db, `channel-${index}`, `Channel ${index} HD`);
|
||||
}
|
||||
require('../server/services/liveProjectionService').rebuild(db);
|
||||
|
||||
let standardCalls = 0;
|
||||
let epgCalls = 0;
|
||||
const started = Date.now();
|
||||
const page = getChannelPage({ languages: [], q: '', epgSources: [{ id: 99, type: 'epg', enabled: true }] }, db, {
|
||||
iptvOrgCatalog: { findMatch: () => { standardCalls += 1; return null; } },
|
||||
epgMatching: { findBestMatch: () => { epgCalls += 1; return null; } }
|
||||
});
|
||||
|
||||
assert.equal(page.channels.length, 500);
|
||||
assert.equal(standardCalls, 0);
|
||||
assert.equal(epgCalls, 0);
|
||||
assert.ok(Date.now() - started < 1000);
|
||||
});
|
||||
|
||||
test('broad searches above the enrichment guard remain bounded', () => {
|
||||
const db = createProjectionDb();
|
||||
for (let index = 0; index < 300; index++) seedProjectionChannel(db, `news-${index}`, `News ${index}`);
|
||||
require('../server/services/liveProjectionService').rebuild(db);
|
||||
let calls = 0;
|
||||
const page = getChannelPage({ q: 'news', epgSources: [] }, db, {
|
||||
iptvOrgCatalog: { findMatch: () => { calls += 1; return null; } },
|
||||
epgMatching: { findBestMatch: () => { calls += 1; return null; } }
|
||||
});
|
||||
assert.equal(page.channels.length, 300);
|
||||
assert.equal(calls, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user