Cap transient preview retries and close dead hosts
This commit is contained in:
@@ -1063,6 +1063,61 @@ void (async () => {
|
||||
assert.equal(second.calls[0].before, "499");
|
||||
});
|
||||
|
||||
await test("transient preview failures give up after the attempt limit", async () => {
|
||||
const backend = new FakeBackend([
|
||||
{
|
||||
messages: [
|
||||
message("650", {
|
||||
embeds: [
|
||||
{
|
||||
type: "video",
|
||||
url: "https://gfycat.com/deadclip",
|
||||
title: null,
|
||||
provider: "Gfycat",
|
||||
videoUrl: "https://gfycat.com/deadclip",
|
||||
imageUrl: null,
|
||||
thumbnailUrl: "https://thumbs.gfycat.com/dead.webp"
|
||||
}
|
||||
]
|
||||
})
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
const engine = new ScrapeEngine({
|
||||
rootDir: root,
|
||||
pageSize: 2,
|
||||
pageMinMs: 0,
|
||||
pageMaxMs: 0,
|
||||
sleep: async () => {},
|
||||
random: () => 0,
|
||||
log: () => {},
|
||||
previews: true,
|
||||
previewMaxAttempts: 3,
|
||||
download: {
|
||||
fetchImpl: async () => {
|
||||
throw new Error("fetch failed");
|
||||
},
|
||||
minGapMs: 0,
|
||||
maxGapMs: 0,
|
||||
sleep: async () => {}
|
||||
}
|
||||
});
|
||||
|
||||
const started = await engine.start({ channelId: "128", guildId: null, mode: "links", backend });
|
||||
await engine.processQueue();
|
||||
|
||||
const dir = join(root, started.id);
|
||||
for (let pass = 0; pass < 3; pass++) await engine.backfillPreviews(started.id);
|
||||
|
||||
const store = new ScrapeStore(dir);
|
||||
const row = store.queryMedia({ kind: "video" })[0];
|
||||
assert.equal(row.preview_attempts, 3);
|
||||
assert.match(String(row.preview_error), /^unreachable after 3 attempt/);
|
||||
assert.equal(store.pendingPreviews(10, true).length, 0);
|
||||
store.close();
|
||||
});
|
||||
|
||||
await test("backfillPreviews fills rows left by a preview-less walk", async () => {
|
||||
const backend = new FakeBackend([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user