fix: enforce house worker request spacing and ignore local secrets

This commit is contained in:
2026-10-11 21:14:41 +00:00
parent 0846cf7d77
commit 4ea0ba2d48
2 changed files with 6 additions and 2 deletions

4
.gitignore vendored
View File

@@ -16,6 +16,10 @@ Thumbs.db
!.env.example
!.env.test
# Home worker credentials and browser cookies
/house.env
/.house-worker-profile/
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View File

@@ -58,7 +58,7 @@ const config = {
),
slowEveryHours: number(process.env.HOUSE_SLOW_EVERY_HOURS, 12),
slowMaxPages: number(process.env.HOUSE_SLOW_MAX_PAGES, 80),
minGapMs: number(process.env.HOUSE_MIN_GAP_SECONDS, 8) * 1000,
minGapMs: Math.max(8, number(process.env.HOUSE_MIN_GAP_SECONDS, 8)) * 1000,
dailyBudget: number(process.env.HOUSE_DAILY_BUDGET, 1500),
fetchMode: (process.env.HOUSE_FETCH_MODE ?? 'fetch') as 'fetch' | 'browser',
userAgent:
@@ -115,7 +115,7 @@ function slowBudgetLeft() {
async function waitForTurn() {
resetBudget();
if (budgetUsed >= config.dailyBudget) throw new Error('Daily request budget used up');
const gap = config.minGapMs * (0.8 + Math.random() * 0.7);
const gap = config.minGapMs * (1 + Math.random() * 0.5);
const wait = lastRequestAt + gap - Date.now();
if (wait > 0) await sleep(wait);
lastRequestAt = Date.now();