I have a custom function which open a browser to get cookies. The problem is my machine is very small and what would happen when multiple sessions are being made it will try to open many browsers at the same time. Can I somehow make the creation of sessions sequential ? so even though I need 1000s of sessions but at any point in time only one session is created and no session can be created in parallel. So only one browser instance will be running at any point in time.
createSessionFunction: async(sessionPool,options) => {
var new_session = new Session({ sessionPool });
var proxyurl = await proxyConfigurationDE.newUrl(new_session.id);
console.log(proxyurl, new_session.id);
var cookies_g = await getCookiesDE(proxyurl,'https://www.example.com');
console.log("cookies from playwright..",cookies_g);
new_session.setCookies(
cookies_g,
'https://www.example.com'
);
console.log("Checking cookies set..", new_session.getCookieString("example.com"))
return new_session;
}