Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Feat/race timeout #470

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/utils/municipality/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import * as cheerio from "cheerio";
import { CheerioAPI } from "cheerio";
import puppeteer from "puppeteer";
import { setTimeout } from "timers/promises";

import {
customPrimaryMenuItemsDataElement,
customSecondaryMenuItemsDataElement,
Expand Down Expand Up @@ -356,9 +358,12 @@ const getRandomThirdLevelPagesUrl = async (
continue;
}

await page.waitForNetworkIdle({
idleTime: 1000,
});
await Promise.race([
setTimeout(10000),
page.waitForNetworkIdle({
idleTime: 1000,
}),
]);

const currentCountPages = (await page.$$(linkDataElement)).length;
if (currentCountPages === maxCountPages) {
Expand Down
Loading