I am currently using p-queue in combination with Puppeteer. What I want to achieve is to add the current function to the queue if an exception gets thrown. I am running with concurrency set to 3.
I have the following snippets:
getAccounts
is simply a method for parsing a json file.
async init() {
let accounts = await this.getAccounts();
accounts.map(async () => {
await queue.add(() => this.test());
});
await queue.onIdle();
console.log("Done");
}
async test() {
const browser = await puppeteer.launch({headless: false});
try {
const page = await browser.newPage();
await page.goto(this._url);
if (Math.floor(Math.random() * 10) > 4) {
throw new Error("Simulate error");
}
await browser.close();
} catch (error) {
await browser.close();
await queue.add(() => this.test());
console.log(error);
}
}
When it goes into the catch, the queue just stops. I am not sure if my implementation is right. But it also does not execute console.log("Done");
.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too