fix: enforce house worker request spacing and ignore local secrets
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user