I’m trying to get a basic Puppeteer example working. It seems to be hanging on something. Any ideas?
https://www.developers.google.com/web/tools/puppeteer isn’t a valid URL, so the page.goto hangs with err_name_not_resolved. You want https://developers.google.com/web/tools/puppeteer I think.
Whoops, good catch. However, still doesn’t work after providing a valid URL.
I started a discussion on the Puppeteer side of things, too: https://github.com/GoogleChrome/puppeteer/issues/2143
you can see why it fails in the Logs:
TypeError: path must be absolute or specify root to res.sendFile
at ServerResponse.sendFile (/rbd/pnpm-volume/2ba2fb12-3226-4fc6-a9ae-a9cf09896d19/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/response.js:421:11)
at app.get (/app/server.js:14:14)
at <anonymous>
Basically, the issue is that when the endpoint fails, you didn’t write a response for the browser, but only in the logs. Try adding this in the catch
, after console.log
:
response.status(503).end(error.message);
This way you can see the error from the preview too
By the way, to actually fix the error you can write:
response.sendFile('/app/puppeteer.png');
instead of
response.sendFile('puppeteer.png');
Feel free to remix https://glitch.com/edit/#!/puppeteer-sample