Skip to content

Commit 00a0687

Browse files
authored
fix: exception handling TimeoutError (jef#20) (jef#21)
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
1 parent d3ec4bc commit 00a0687

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,20 @@ async function lookup(store: Store) {
3939
width: Config.page.width
4040
});
4141

42-
await page.goto(link.url, {waitUntil: 'networkidle0'});
42+
const graphicsCard = `${link.brand} ${link.model}`;
43+
44+
try {
45+
await page.goto(link.url, {waitUntil: 'networkidle0'});
46+
} catch {
47+
Logger.error(`✖ [${store.name}] ${graphicsCard} skipping; timed out`);
48+
return;
49+
}
4350

4451
const bodyHandle = await page.$('body');
4552
const textContent = await page.evaluate(body => body.textContent, bodyHandle);
4653

4754
Logger.debug(textContent);
4855

49-
const graphicsCard = `${link.brand} ${link.model}`;
50-
5156
if (isOutOfStock(textContent, link.oosLabels)) {
5257
Logger.info(`✖ [${store.name}] ${graphicsCard} is still out of stock`);
5358
} else {

0 commit comments

Comments
 (0)