Separated and improved request throttling.

This commit is contained in:
2026-09-08 00:01:24 +02:00
parent 3e8ed79ccc
commit 8b52d73a65
5 changed files with 72 additions and 12 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ const phash = require('sharp-phash');
const { agentFor } = require('../proxy');
const logger = require('../logger')(__filename);
const limiter = require('../limiter').items;
const limiterFor = require('../limiter');
// bhttp has no timeout at all by default - if the server (or, more likely, a proxy tunnel
// that connects fine but then never relays anything) just stops responding mid-request without
@@ -42,7 +42,7 @@ async function fetchItem(url, attempt, context) {
// whichever of proxied/direct is NOT what it'd normally get - see resolveProxyUrl()
const flip = config.proxy.retryFlipped && attempt > 0;
const res = await limiter.schedule(async () => withTimeout(
const res = await limiterFor(url).schedule(async () => withTimeout(
bhttp.get(url, { headers: context.headers, agent: agentFor(url, { flip }) }),
config.fetch.timeout,
url,