Separated and improved request throttling.
This commit is contained in:
+2
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user