Preserve per-source pacing across queue jobs and add source pause
This commit is contained in:
1 parent
a08e847932
commit
a22913129a
8 files changed
+76
-7
No files matched your search
@@ -54,3 +54,15 @@ test('a guarded 403 stops immediately without redirect or retry', async () => {
|
||||
await assert.rejects(http.get('https://weebcentral.com/series/X', { accept: 'text/html' }), StopScrapeError);
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
|
||||
test('separate jobs on one source retain the configured request gap', async () => {
|
||||
const gateKey = `fixture-${Date.now()}-${Math.random()}`;
|
||||
const transport = async () => ({ status: 200, ok: true });
|
||||
const first = new SlowHttp({ gateKey, minMs: 40, maxMs: 40, transport });
|
||||
await first.get('https://example.org/one');
|
||||
const second = new SlowHttp({ gateKey, minMs: 40, maxMs: 40, transport });
|
||||
assert.equal(second.gate, first.gate);
|
||||
const started = Date.now();
|
||||
await second.get('https://example.org/two');
|
||||
assert.ok(Date.now() - started >= 30, 'a new job must not reset its source delay');
|
||||
});
|
||||
Reference in new issue
Block a user