Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simutaneous screenshots doesn't work beyond 2 instances of chromy #121

Open
bhagn opened this issue Sep 26, 2019 · 0 comments
Open

Simutaneous screenshots doesn't work beyond 2 instances of chromy #121

bhagn opened this issue Sep 26, 2019 · 0 comments

Comments

@bhagn
Copy link

bhagn commented Sep 26, 2019

I have seen the existing issues about running chromy in parallel - but my issues seems to be a bit weird. When there are more than 2 instances of chromy created simultaneously to take screenshot of a different URLs - randomly just 2 of them work, and the remaining don't even respond. The chrome processes for the remaining ones just continue running. Here's the sample code - works fine on mac, seeing the issue on ubuntu 18.04

router.get('/export/:id', async function() {
  try {
    await exportPage(req.params.id);
    res.json({result: 'success'})
  } catch(e) {
    res.status(500);
    res.json({result: 'failure'})
  }
});
async function exportPage(id) {
  let url = 'https://localhost:8000/page/id';  // some valid URL
  let port = await getPort();

  let chromy = new Chromy({
     visible: false,
     port: port,
     launchBrowser: true,
     chromeFlags: [
       '--ignore-certificate-errors',
       '--allow-insecure-localhost',
       '--window-size=1200,800'
     ]
  });

  return chromy.chain()
    .goto(url)
    .wait(10000)
    .evaluate(_ => {
         // some browser specific JS evaluation, 
    })  // all instances run till here with no issues. 
    .screenshotDocument()  // only 2 instances succeed in running beyond this.
    .result(screenshot => {
        // write screenshot to file
    })
    .end()
    .then(_ => {
        console.log('Successful');
    })
    .catch(err => {
        console.error(err);
        throw err;
    })
    .finally(_ => {
        chromy.close();
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant