Retry outbound read syncs for up to 24 hours

This commit is contained in:
Evan Hahn 2021-07-23 17:02:36 -05:00 committed by GitHub
parent fc33e9be41
commit 18140c4a9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 366 additions and 19 deletions

View file

@ -204,6 +204,42 @@ describe('JobQueue', () => {
assert.isEmpty(store.storedJobs);
});
it('passes the attempt number to the run function', async () => {
const attempts: Array<number> = [];
const store = new TestJobQueueStore();
class TestQueue extends JobQueue<string> {
parseData(data: unknown): string {
return z.string().parse(data);
}
async run(
_: unknown,
{ attempt }: Readonly<{ attempt: number }>
): Promise<void> {
attempts.push(attempt);
throw new Error('this job always fails');
}
}
const queue = new TestQueue({
store,
queueType: 'test',
maxAttempts: 6,
});
queue.streamJobs();
try {
await (await queue.add('foo')).completion;
} catch (err: unknown) {
// We expect this to fail.
}
assert.deepStrictEqual(attempts, [1, 2, 3, 4, 5, 6]);
});
it('makes job.completion reject if parseData throws', async () => {
class TestQueue extends JobQueue<string> {
parseData(data: unknown): string {