fix: stop three loops that retry forever, and let budget dead letters recover
The event outcome worker re-requested PSTG and GROQ on every poll for as long as the process lived, because a fetch failure only logged and continued while the prediction stayed pending. Ten requests every five minutes, indefinitely. Per ticker backoff now doubles to an hour, so a symbol with no market data costs one request an hour instead of one a minute. It also translates dotted tickers the same way the autonomy worker does, which is why that helper moved into the shared price module rather than being copied. The gdelt loop had no pause on its error path at all, so once the api started refusing connections it spun through failures continuously, burning cpu and filling the log with the same stack. It has been doing that for days. Backs off to half an hour now and resets on success. isTransientCoordinatorFailure matched 408, 429 and 5xx but not a budget 402/403, so the 380 jobs that dead-lettered during the exhausted quota window could never come back on their own, including 55 live events. Budget failures are transient in a way an ordinary auth failure is not, and a wrong key still dies permanently because it says invalid or unauthorized rather than naming credits. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
// Yahoo writes class shares with a dash, BRK.B is BRK-B there. Our allowlist is
|
||||
// full of dotted symbols and every one of them 404s forever otherwise.
|
||||
function yahooSymbol(symbol) {
|
||||
return String(symbol || '').trim().toUpperCase().replace(/\./g, '-');
|
||||
}
|
||||
|
||||
function addTradingDays(date, days) {
|
||||
const value = new Date(`${date}T00:00:00Z`);
|
||||
let remaining = Math.max(0, Number(days) || 0);
|
||||
@@ -45,4 +51,4 @@ function calculateOutcome(prediction, instrumentHistory, benchmarkHistory) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { addTradingDays, nearestOnOrAfter, calculateOutcome };
|
||||
module.exports = { addTradingDays, nearestOnOrAfter, barOnOrAfter, calculateOutcome, yahooSymbol };
|
||||
|
||||
+11
-1
@@ -65,7 +65,11 @@ async function runAllIngestions() {
|
||||
return results;
|
||||
}
|
||||
|
||||
const GDELT_BACKOFF_START_MS = 30 * 1000;
|
||||
const GDELT_BACKOFF_MAX_MS = 30 * 60 * 1000;
|
||||
|
||||
function startScheduler() {
|
||||
let gdeltBackoffMs = 0;
|
||||
const runRss = async () => {
|
||||
await runSource('rss', fetchRssArticles);
|
||||
};
|
||||
@@ -84,8 +88,14 @@ function startScheduler() {
|
||||
await fetchGdeltArticles(async (articles) => {
|
||||
await ingestBatch("gdelt", articles);
|
||||
});
|
||||
gdeltBackoffMs = 0;
|
||||
} catch (error) {
|
||||
console.error("gdelt ingestion failed:", error);
|
||||
// No pause here at all previously, so once gdelt started refusing
|
||||
// connections this span burned cpu and filled the log with the same
|
||||
// stack indefinitely. It has been failing for days on end.
|
||||
gdeltBackoffMs = Math.min(GDELT_BACKOFF_MAX_MS, gdeltBackoffMs ? gdeltBackoffMs * 2 : GDELT_BACKOFF_START_MS);
|
||||
console.error(`gdelt ingestion failed, retrying in ${Math.round(gdeltBackoffMs / 1000)}s:`, error.message);
|
||||
await sleep(gdeltBackoffMs);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user