Hey! Is there a way to set userDataDir in puppeteer.launch()?
Hey!
Is there a way to set userDataDir in puppeteer.launch()?
Is there a way to set userDataDir in puppeteer.launch()?
puppeteer-extra ?
async function getSession(browser) {
const sessions = await puppeteer.sessions(browser);
console.log(`getSession: sessions - ${JSON.stringify(sessions)}`);
const sessionsIds = sessions
.filter((v) => {
return !v.connectionId;
})
.map((v) => {
return v.sessionId;
});
console.log(`getSession: Available sessionsIds - ${JSON.stringify(sessionsIds)}`);
if (sessionsIds.length !== 0)
try {
const sessionId = sessionsIds[Math.floor(Math.random() * sessionsIds.length)];
console.log(`getSession: re-using session ${sessionId}`);
return await puppeteer.connect(browser, sessionId);
} catch (e) {
console.log(`getSession: Error connecting to session - Might already be in use. ${JSON.stringify(await puppeteer.sessions(browser))}`);
}
try {
console.log(`getSession: creating new session`);
return await puppeteer.launch(browser);
} catch (e) {
console.log(`getSession: Error creating new session - ${JSON.stringify(await puppeteer.history(browser))}`);
}
}{
text: 'A request to the Cloudflare API
(/accounts/XXXXXXXXXXX/workers/scripts/browser-worker/edge-preview) failed.',
notes: [
{
text: 'workers.api.error.no_access_to_browser_worker [code: 10088]'
}
],
location: undefined,
kind: 'error',
code: 10088
}