stereobooster/react-snap

Error: Failed to launch chrome!

AndreaMastracchio opened this issue · 1 comments

Hi Guys! thank you in advance for the help.

I am getting this error in deploying my App initialized with CRA.

"Error: Failed to launch chrome!
(chrome:4474): Gtk-WARNING **: 13:53:38.045: cannot open display:
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/tmp/build_68def651/node_modules/react-snap/node_modules/puppeteer/lib/Launcher.js:348:14)
at ChildProcess. (/tmp/build_68def651/node_modules/react-snap/node_modules/puppeteer/lib/Launcher.js:338:60)
at ChildProcess.emit (events.js:327:22)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)"

I tried to add to package.json that line

""reactSnap": {
"puppeteerArgs": [
"--no-sandbox",
"--disable-setuid-sandbox"
]
}
"
and the buildpack on heroku:

https://github.com/jontewks/puppeteer-heroku-buildpack

But it's still not working.

Could you please help me?

Thanks,
Andrea

Hi! adding on my server.js

"app.get('*', function(req, res) {
var urlToScreenshot = parseUrl(req.query.url);
if (validUrl.isWebUri(urlToScreenshot)) {
(async() => {
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.goto(urlToScreenshot);
await browser.close();
})();
} else {
res.send('Invalid url: ' + urlToScreenshot);
}

});"

resolve issue!