fix(search): Filter zuverlässiger durch allowTruncate
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m16s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m16s
Vorher warf fetchText einen Fehler, sobald eine Seite >512 KB war — bei modernen Rezeptseiten (eingebettete Bundles, base64-Bilder) läuft das praktisch immer voll. Der Catch-Block hat dann hasRecipe auf NULL gelassen, und der Treffer ging ungefiltert durch. Neue FetchOptions.allowTruncate: true → wir bekommen die ersten 512 KB (das reicht für <head> mit og:image und JSON-LD) statt eines Throws. Timeout auf 8s erhöht, weil der Pi manchmal langsamer ist. Migration 008 räumt alte NULL-has_recipe-Einträge aus dem Cache, damit sie beim nächsten Search frisch klassifiziert werden statt weitere 30 Tage falsch gecached zu bleiben. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,20 @@ describe('fetchText', () => {
|
||||
});
|
||||
await expect(fetchText(`${baseUrl}/`, { timeoutMs: 150 })).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('allowTruncate returns first maxBytes instead of throwing', async () => {
|
||||
const head = '<html><head><title>hi</title></head>';
|
||||
const filler = 'x'.repeat(2000);
|
||||
server.on('request', (_req, res) => {
|
||||
res.writeHead(200, { 'content-type': 'text/html' });
|
||||
res.end(head + filler);
|
||||
});
|
||||
const text = await fetchText(`${baseUrl}/`, { maxBytes: 100, allowTruncate: true });
|
||||
// First 100 bytes of body — should contain the <head> opening at least
|
||||
expect(text.length).toBeLessThanOrEqual(2048); // chunk boundary may overshoot exact bytes slightly
|
||||
expect(text).toContain('<html>');
|
||||
expect(text).toContain('<head>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchBuffer', () => {
|
||||
|
||||
Reference in New Issue
Block a user