Merge pull request 'fix(writer-pipeline): stop eurohandball sitemap timeout error loop (BIT-25342)' (#22) from fix/BIT-25342-eurohandball-sitemap-timeout into main
This commit was merged in pull request #22.
This commit is contained in:
commit
129c43336b
5 files changed
+46
-6
No files matched your search
@@ -31,9 +31,11 @@
|
||||
"url": "https://www.eurohandball.com/sitemap.xml",
|
||||
"enabled": true,
|
||||
"topics": ["handball", "ehf"],
|
||||
"maxItems": 25,
|
||||
"pathIncludes": ["/competitions/", "/news/", "/calendar/", "/match-center/"],
|
||||
"note": "EHF/Eurohandball: main sitemap is huge; path filter skips /club/ noise; pages fetched for title/summary (no LLM)."
|
||||
"maxItems": 20,
|
||||
"pathIncludes": ["/news/", "/match-center/"],
|
||||
"timeoutMs": 25000,
|
||||
"pageTimeoutMs": 35000,
|
||||
"note": "EHF/Eurohandball: main sitemap is huge; path filter keeps news/match pages only (competition index URLs are heavy and not article content — BIT-25342)."
|
||||
},
|
||||
{
|
||||
"id": "record_pt_main",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { initReporter, reportMessage, flush } from './lib/errorReporter.js';
|
||||
import { reportCycleErrors } from './lib/cycle-error-report.js';
|
||||
import { cycleErrorMessageLevel, reportCycleErrors } from './lib/cycle-error-report.js';
|
||||
|
||||
describe('errorReporter', () => {
|
||||
it('no-ops when disabled without token', async () => {
|
||||
@@ -12,6 +12,31 @@ describe('errorReporter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('cycleErrorMessageLevel', () => {
|
||||
it('downgrades per-page sitemap probe failures to warning', () => {
|
||||
assert.equal(
|
||||
cycleErrorMessageLevel(
|
||||
'sitemap eurohandball_sitemap page (https://www.eurohandball.com/en/competitions/foo/): The operation was aborted due to timeout',
|
||||
),
|
||||
'warning',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps whole-source sitemap failures as error', () => {
|
||||
assert.equal(
|
||||
cycleErrorMessageLevel('sitemap eurohandball_sitemap (https://www.eurohandball.com/sitemap.xml): HTTP 503'),
|
||||
'error',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps sitemap truncation as warning', () => {
|
||||
assert.equal(
|
||||
cycleErrorMessageLevel('sitemap fpa: no pathIncludes and 500 URLs — truncating to 200 before maxItems'),
|
||||
'warning',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('reportCycleErrors', () => {
|
||||
it('maps ingest error strings without throwing when reporter disabled', async () => {
|
||||
initReporter({ disabled: true, token: '' });
|
||||
|
||||
@@ -285,11 +285,12 @@ export async function ingestAllSources(
|
||||
errors.push(`sitemap ${source.id}: no URLs after filters`);
|
||||
continue;
|
||||
}
|
||||
const pageTimeoutMs = source.pageTimeoutMs ?? source.timeoutMs ?? 30000;
|
||||
let ok = 0;
|
||||
for (const entry of slice) {
|
||||
try {
|
||||
const html = await fetchTextWithRetry(entry.loc, {
|
||||
timeoutMs,
|
||||
timeoutMs: pageTimeoutMs,
|
||||
retries,
|
||||
accept: 'text/html, application/xhtml+xml, */*',
|
||||
});
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { reportError, reportMessage } from './errorReporter.js';
|
||||
|
||||
/** Map ingest cycle strings to hub severity (partial sitemap page failures are warnings, not loops). */
|
||||
export function cycleErrorMessageLevel(message: string): 'warning' | 'error' {
|
||||
if (!message.startsWith('sitemap')) return 'error';
|
||||
if (message.includes('truncating')) return 'warning';
|
||||
// Per-URL HTML probe failed but other pages in the same source may have succeeded.
|
||||
if (/^sitemap .+ page \(https?:\/\//.test(message)) return 'warning';
|
||||
return 'error';
|
||||
}
|
||||
|
||||
/** Report writer-pipeline cycle failures to errors.bitreport.pt (ingest, publish, config). */
|
||||
export function reportCycleErrors(
|
||||
site: string,
|
||||
@@ -7,7 +16,7 @@ export function reportCycleErrors(
|
||||
context: Record<string, unknown> = {},
|
||||
): void {
|
||||
for (const message of errors) {
|
||||
const level = message.startsWith('sitemap') && message.includes('truncating') ? 'warning' : 'error';
|
||||
const level = cycleErrorMessageLevel(message);
|
||||
reportMessage(message, level, {
|
||||
site,
|
||||
component: 'writer-pipeline',
|
||||
|
||||
@@ -12,7 +12,10 @@ export interface IngestSource {
|
||||
/** For sitemap: keep URLs whose path includes any of these substrings */
|
||||
pathIncludes?: string[];
|
||||
retries?: number;
|
||||
/** Timeout for fetching the sitemap XML (and RSS/HTML source URL). */
|
||||
timeoutMs?: number;
|
||||
/** Timeout for each HTML page fetched from sitemap URL entries (defaults to timeoutMs or 30s). */
|
||||
pageTimeoutMs?: number;
|
||||
}
|
||||
|
||||
/** @deprecated Use IngestSource with kind rss — kept for legacy JSON configs */
|
||||
|
||||
Reference in new issue
Block a user