thomasdondorf / puppeteer-cluster

Puppeteer Pool, run a cluster of instances in parallel
MIT License
3.2k stars 307 forks source link

Has anyone managed to use separate data for each browser? #532

Open antizhyk opened 8 months ago

antizhyk commented 8 months ago

Hey, everybody. I'm trying to make puppeter-cluster for each task create its own browser instance and it is very important that this browser instance is launched on certain data from the past session in a normal puppeter they are passed through userDataDir when using the launch method.

I found the perBrowserOptions parameter to which you can pass the configurations for the individual browser instance. But how do I, for example, specify which of the previously passed browser parameters in perBrowserOptions I want to use when launching cluster.queue() is unclear.

Here is my example code where I run a separate browser instance on puppeter This is where I'm loading data from past account sessions for the browser.

     this.browser = await this.puppeteer.launch({
        userDataDir: `./tmp/${accountData?._id}`,
        headless: false,
        args: args,
      });

Now I'm trying to set up work for several accounts at the same time and each account needs its own browser and puppeter-cluster seems to be suitable for this, but I've encountered a problem, I can't configure session reuse.