-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to manually request browser restart #310
base: master
Are you sure you want to change the base?
Conversation
How to install and using this ? |
Hi @tenkuken Usage create the cluster with Then when you want to schedule browser restart just call Please update here how is that working for you . |
Unfortunately, i'm using CONCURRENCY_BROWSER for perbrowserOptions. Thank you for update. |
But if you’re using CONCURRENCY_BROWSER why do you need this restart? |
I'm sorry, It is automatically starts new browser for each task. |
I try to execute private async doWork() {
const doneJob = this.allTargetCount - this.jobQueue.size() - this.workersBusy.length;
if (doneJob > 0 && doneJob % this.options.queueLimit === 0) {
if (this.options.queueLimitRestart) {
// this.requestRestart();
this.requestRestart();
// await Promise.all(this.workers.map(async (worker) => await worker.browser.repair()));
Logger.log('max loop restart cluster', 'Puppeteer Cluster');
} else {
throw new Error('Queue limit reached');
}
}
... |
Added pull request thomasdondorf#310 from puppeteer-cluster
Option to request Cluster to restart the browser manually.
Motivation: sometimes when Google Chrome is running too long the RAM usage is increases.
Restart chrome from time to time (for example every 1k jobs) may be handy.
I added an implementation for that.
Restart may be handy for other reasons too. (Update some data from data dir ...)
Implementation:
Added
public abstract requestRestart(): void;
toConcurrencyImplementation
Relevant mostly to to
SingleBrowserImplementation
But as SingleBrowserImplementation extends ConcurrencyImplementation I couldn't find a way not to put it in the interface.
I tested It against my use case and it worked.