Skip to content

Commit

Permalink
Increase timeout for searches from 10 to 30 seconds
Browse files Browse the repository at this point in the history
Fixes #5, but timeout handling still needs to be improved in general.
  • Loading branch information
Sanqui committed Jun 9, 2022
1 parent e9db4b1 commit 74a49a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/crawler/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CaptureTool } from '../captureTools';

puppeteer.use(StealthPlugin());

const DISCARD_VERSION = '0.1.3';
const DISCARD_VERSION = '0.1.4';

type LogFunction = (...args: unknown[]) => Promise<void>;

Expand Down
9 changes: 5 additions & 4 deletions src/crawler/projects/discord/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ export class ChannelDiscordTask extends DiscordTask {
while (!searchFinished) {
await crawler.page.waitForSelector(resultsSelector);

const interval = 200;
for (let i = 0; i < 10_000/interval; i++) {
const msWaitFor = 30_000;
const msInterval = 100;
for (let i = 0; i < msWaitFor/msInterval; i++) {
resultsText = await crawler.page.$eval(resultsSelector, el => el.textContent);
if (!["Searching…", "Indexing…"].includes(resultsText.trim())) {
searchFinished = true;
break;
}

await crawler.page.waitForTimeout(interval);
await crawler.page.waitForTimeout(msInterval);
}
if (searchFinished) {
// We're either going to get the search results, or an error
Expand All @@ -128,7 +129,7 @@ export class ChannelDiscordTask extends DiscordTask {
}
}
} else {
throw Error("Did not get search results after 10 seconds.");
throw Error(`Did not get search results after ${msWaitFor / 1_000} seconds.`);
}
}
}
Expand Down

0 comments on commit 74a49a0

Please sign in to comment.