Closed ClassAxion closed 1 year ago
Yes, this will be implemented eventually.
Can I know when approximately? Then I will know what to do next with my software
This is only for convenience, I belive, that you could set env variable directly from source now.
I'm using worker_threads
for now that have separate environment so I'm able to set different FINGERPRINT_CWD
but that consumes more RAM
Have you tried to assign to process.env
. Or you want to have different dir in one process?
I need different workingDir
in one process
Workaround for now using decache
pkg for puppeteer-with-fingerprints
import decache from "decache";
async function launch(workingDir: string) {
process.env.FINGERPRINT_CWD = workingDir;
decache("puppeteer-with-fingerprints");
const { plugin } = require("puppeteer-with-fingerprints");
const browser = await plugin.launch({
headless: false,
});
const page = await browser.newPage();
await page.goto("http://ip.bablosoft.com/");
}
(async () => {
await Promise.all([
launch("./data1"),
launch("./data2"),
launch("./data3"),
]);
})();
@ClassAxion now it's possible to use the setWorkingFolder method:
plugin.setWorkingFolder('./data1');
const browser1 = await plugin.launch({ headless: false });
plugin.setWorkingFolder('./data2');
const browser2 = await plugin.launch({ headless: false });
This is a replacement for similar settings via environment variables.
At the moment, consider the problem solved - if this is not the case or you have other questions, please, open a separate ticket.
Please note that your code above is not thread-safe, since one of the calls can override the path to the working folder, such code needs to be synchronized.
For now, we have to use
cluster
orworker_threads
to use multiple browser with differentFINGERPRINT_CWD
. I think, that it will be easiest to use some argument to control theworkingDir
so we will be able to use multiple browsers with differentFINGERPRINT_CWD
in one NodeJS script so the RAM usage will be less. I don't know if this is possible but I initially checked and there should be no problems. Of course,FINGERPRINT_CWD
may still be supported.