fix: back off after Reddit access denials
This commit is contained in:
1 parent
e8b730b592
commit
53e9a44a5c
5 files changed
+81
-14
No files matched your search
@@ -55,4 +55,18 @@ describe('RedditRequestCoordinator', () => {
|
||||
await second;
|
||||
expect(sleeps).toEqual([16_000]);
|
||||
});
|
||||
|
||||
it('paces a queued request after a failed attempt without an explicit cooldown', async () => {
|
||||
let now = 0;
|
||||
const sleeps: number[] = [];
|
||||
const coordinator = new RedditRequestCoordinator(6_500, {
|
||||
now: () => now,
|
||||
sleep: async (ms) => { sleeps.push(ms); now += ms; },
|
||||
});
|
||||
|
||||
await expect(coordinator.schedule(async () => { throw new Error('403'); })).rejects.toThrow('403');
|
||||
await coordinator.schedule(async () => undefined);
|
||||
|
||||
expect(sleeps).toEqual([6_500]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user