Keep HTTP responsive during confluence replay.
CI / Test (push) Canceled after 0s
CI / Build and push (push) Canceled after 0s

Boot replay was a tight CPU loop that wedged the Unraid backend, so login hit the 8s client timeout. Yield every few as-of dates, shorten the boot ledger fill, and make /health a cheap liveness check.
This commit is contained in:
Investor Flow Build
2026-09-09 10:16:36 -04:00
parent 7426103d73
commit 0b901fc190
3 changed files with 12 additions and 3 deletions
@@ -301,7 +301,12 @@ export async function runConfluenceReplay(
const weeklyFull = await provider.resolveAsOf(symbol, '1wk', '9999-12-31');
const benchFull = await provider.resolveAsOf(BENCHMARK_SYMBOL, '1d', '9999-12-31');
let asOfN = 0;
for (const asOf of slice) {
asOfN += 1;
if (asOfN % 4 === 0) {
await new Promise<void>((r) => setImmediate(r));
}
const dailyCut = daily.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
const weeklyCut = weeklyFull.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
const benchCut = benchFull.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
@@ -391,6 +396,7 @@ export async function fillLearningLedger(
complete: batch.complete,
};
if (batch.evaluationsStored === 0) break;
await new Promise<void>((r) => setImmediate(r));
}
return { ...last, ledger: await learningLedgerStatus(db, cache) };
}