pptraas.com icon indicating copy to clipboard operation
pptraas.com copied to clipboard

Launch new tab instead of launch new browser

Open vincent178 opened this issue 7 years ago • 1 comments

Hi,

Thanks for the nice repo, it is very helpful. Just one issue:

app.all('*', async (request, response, next) => {
  response.locals.browser = await puppeteer.launch({
    dumpio: true,
    // headless: false,
    // executablePath: 'google-chrome',
    args: ['--no-sandbox', '--disable-setuid-sandbox'], // , '--disable-dev-shm-usage']
  });

  next(); // pass control on to routes.
});

This code shows that we create a new browser every time for a new request, this requires more memory and more load time than create a new tab for the same browser.

I wonder what's the thought behind this?

Thanks, Vincent

vincent178 avatar Jun 11 '18 05:06 vincent178

Generally it keeps things more ephemeral starting a new instance. Others have found the same: https://docs.browserless.io/blog/2018/06/04/puppeteer-best-practices.html

Puppeteer just introduce browser contexts for cases like this. The feature basically open Chrome in incognito tab but you can use the same browser instance to span across multiple contexts, yet keep cookie stores and session data separate.

On Sun, Jun 10, 2018, 10:39 PM vincent178 [email protected] wrote:

Hi,

Thanks for the nice repo, it is very helpful. Just one issue:

app.all('*', async (request, response, next) => { response.locals.browser = await puppeteer.launch({ dumpio: true, // headless: false, // executablePath: 'google-chrome', args: ['--no-sandbox', '--disable-setuid-sandbox'], // , '--disable-dev-shm-usage'] });

next(); // pass control on to routes. });

This code shows that we create a new browser every time for a new request, this requires more memory and more load time than create a new tab for the same browser.

I wonder what's the thought behind this?

Thanks, Vincent

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GoogleChromeLabs/pptraas.com/issues/34, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOigCYmIVOXdG7rizaKSAZm3eJzZoPDks5t7gJ0gaJpZM4UiF5y .

ebidel avatar Jun 11 '18 15:06 ebidel