-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Error starting Chrome with puppeteer when deploying headless-chrome functions example #1395
Comments
I was able to get the function to work properly (where I see an image in the response when I give it a URL), I had to change my code to the following: 'use strict';
// [START functions_headless_chrome]
const puppeteer = require('puppeteer');
exports.screenshot = async (req, res) => {
console.log('Beginning function')
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox'],
});
console.log('Puppeteer launched');
const page = await browser.newPage();
console.log('Puppeteer page created');
const {url} = req.query;
if (!url) {
return res.send(
'Please provide URL as GET parameter, for example: <a href="?url=https://example.com">?url=https://example.com</a>'
);
}
await page.goto(url);
const imageBuffer = await page.screenshot();
console.log('Screenshot created');
res.set('Content-Type', 'image/png');
res.send(imageBuffer);
};
// [END functions_headless_chrome] I found that I had to add the |
(Followed up internally - @labtopia and I decided to add this to the docs, but we aren't really sure where to put it.) |
I know a few customers are trying to do this (though the performance
currently isn't great). Would be in favor of documenting the use case
rather than throwing it out.
…On Wed, Jul 24, 2019 at 12:49 PM Ace Nassri ***@***.***> wrote:
(Followed up internally - @labtopia <https://github.com/labtopia> and I
decided to add this to the docs, but we aren't really sure where to put it.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1395?email_source=notifications&email_token=AHYELQDTLOWCREBZHLJSH5TQBCW3NA5CNFSM4H6RD3L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2XNLTI#issuecomment-514774477>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHYELQGHEZQNOZS7MF76AWDQBCW3NANCNFSM4H6RD3LQ>
.
--
Stewart Reichling | Product Manager, Serverless | stewartr@google.com |
650.906.3381
|
I actually found this example really interesting. The performance isn't great, but that's exactly why I wanted to use Cloud Functions for this. I have a use case where I need to interact with a website that doesn't have an API, so I could use Puppeteer. And I could use a FaaS service so that I don't have to worry about running out of memory on a VM or App Engine etc from more than one user performing the request that runs Puppeteer at a time. |
HI! I noticed that the examples were removed a few days ago in #1461. Is Puppeteer still supported in Cloud Functions? |
Same questions? I am planing to use it !! |
Yes, it should be supported. We removed these tutorials for a few reasons:
1. they were fairly niche
2. we don't have enough people to support/maintain the associated samples
ourselves.
If you'd like, I can look into adding these to the community-maintained
tutorials repo (https://github.com/GoogleCloudPlatform/community)
cc @steren as FYI
…On Tue, Sep 3, 2019, 7:42 AM clement128 ***@***.***> wrote:
Same questions? I am planing to use it !!
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#1395?email_source=notifications&email_token=AARTZRL4HYG5SDWBL7CIMJTQHZZUTA5CNFSM4H6RD3L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5YNWJQ#issuecomment-527489830>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARTZRM4C2E5DMNWML4CPADQHZZUTANCNFSM4H6RD3LQ>
.
|
I confirm that the OS packages needed to run Headless Chrome (and thus puppeteer) will keep being present in the Cloud Functions environment. |
I was looking at the documentation for Cloud Functions (https://cloud.google.com/functions/docs/concepts/nodejs-10-runtime) and wanted to deploy one of the example functions in this repo, the
headless-chrome
example. My deploy command was based on what I was reading in the docs site:The deploy succeeds, but then in the web browser when I visit the URL, the function displays the expected message if I don't provide the URL query string parameter:
But it fails if I do provide a URL query string parameter, displaying the following message in the browser:
And the following message in the Stackdriver logs for the function:
Despite the error message mentioning "30000 ms", this happens within a few seconds.
The text was updated successfully, but these errors were encountered: