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

page.screenshot() rejects when slowMo >= 1000 and https cert is self-signed even with ignoreHTTPSErrors #563

Closed
jessehattabaugh opened this issue Aug 27, 2017 · 9 comments

Comments

@jessehattabaugh
Copy link

jessehattabaugh commented Aug 27, 2017

I have a webpack-dev-server setup that uses https with a self-signed cert. I set ignoreHTTPSErrors: true when I create the Browser instance, and the page loads no problem. But when I try to take a screenshot I get an unhandled promise rejection error. It's strange because I make the call to page.screenshot() in a try/catch, but for some reason the rejection doesn't get caught.

    try {
        const browser = await puppeteer.launch({
            ignoreHTTPSErrors: true,
            slowMo: 1000,
        });
        const page = await browser.newPage();
        await page.goto(serverUrl);
        await page.screenshot('screenshots/homepage.png');
        browser.close();
    } catch (err) {
        console.error(err);
    }
(node:29232) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (Security.handleCertificateError): Target closed.
(node:29232) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:29232) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): AssertionError [ERR_ASSERTION]: false == true
@aslushnikov
Copy link
Contributor

Looks like the page crashed. I cannot repro this though - would you mind creating a minimalistic repro that I'd be able to run?

Also, running with headless: false and dumpio: true might give more insights:

const browser = await puppeteer.launch({
  ignoreHTTPSErrors: true,
  dumpio: true,
  headless: false
});

@jessehattabaugh
Copy link
Author

What makes you think that the page crashed? I'm new at this so I don't know how to read the errors yet.

I added dumpio: true and I got some new messages

DevTools listening on ws://127.0.0.1:51202/devtools/browser/2aff5bce-154c-418a-adf4-52ea6f36960e
[40354:775:0827/153532.983796:ERROR:CONSOLE(1402)] "Uncaught (in promise) Error: Could not resolve node to reveal.", source: chrome-devtools://devtools/bundled/elements/elements_module.js (1402)
2017-08-27 15:35:34.018 Chromium Helper[40374:502869] Couldn't set selectedTextBackgroundColor from default ()

That selectedTextBackgroundColor got me thinking that maybe if I changed the omitBackground option it would help so I changed

await page.screenshot('screenshots/homepage.png');

to

await page.screenshot({
            path: 'screenshots/homepage.png',
            omitBackground: false,
});

Then the screenshot file got created 👍 !!! But the Promise rejection errors remain the same 👎

It turns out that the screenshot gets created whether I set omitBackground to true or false. So that's probably not related.

Here's a stripped down version that gives me the same errors. https://github.com/jessehattabaugh/puppeteer-issue

Run npm test to run puppeteer and see the errors.

I'm using Mac OS 10.12 and Node 8.4.0

@jessehattabaugh
Copy link
Author

Oh, and if you want to see how it works without https, just change this line https://github.com/jessehattabaugh/puppeteer-issue/blob/master/webpack.config.js#L15

@jessehattabaugh
Copy link
Author

jessehattabaugh commented Sep 5, 2017

The only place I see this error mentioned is this line https://github.com/GoogleChrome/puppeteer/blob/64124df62f4e81999fe1a0ab45c6fb9718a0e413/lib/Page.js#L153

It's preceeded by if (!this._ignoreHTTPSErrors) return;. That seems wrong to me. Why would it stop handling certificate errors when this._ignoreHTTPSErrors == false. Shouldn't it be the other way around?

jessehattabaugh added a commit to jessehattabaugh/puppeteer that referenced this issue Sep 5, 2017
@jessehattabaugh jessehattabaugh changed the title page.screenshot() rejects when https cert is self-signed even with ignoreHTTPSErrors page.screenshot() rejects when slowMo > 0 and https cert is self-signed even with ignoreHTTPSErrors Sep 5, 2017
@jessehattabaugh jessehattabaugh changed the title page.screenshot() rejects when slowMo > 0 and https cert is self-signed even with ignoreHTTPSErrors page.screenshot() rejects when slowMo > 650 and https cert is self-signed even with ignoreHTTPSErrors Sep 5, 2017
@jessehattabaugh jessehattabaugh changed the title page.screenshot() rejects when slowMo > 650 and https cert is self-signed even with ignoreHTTPSErrors page.screenshot() rejects when slowMo > 1000 and https cert is self-signed even with ignoreHTTPSErrors Sep 5, 2017
@jessehattabaugh jessehattabaugh changed the title page.screenshot() rejects when slowMo > 1000 and https cert is self-signed even with ignoreHTTPSErrors page.screenshot() rejects when slowMo >= 1000 and https cert is self-signed even with ignoreHTTPSErrors Sep 5, 2017
@jessehattabaugh
Copy link
Author

jessehattabaugh commented Sep 5, 2017

So I retested the change I made yesterday and it doesn't seem to work anymore. Feels like I never get the same result twice. However, the issue at hand is still occurring in the example repo.

I discovered an important quirk; if you set slowMo: 0, the errors go away entirely. I turned it up gradually and the errors return at around 650 or so, but that seems to change whether you have headless: true|false so it might depend on CPU speed and stuff. slowMo: 1000 reproduces the error fairly consistently, but if you can't reproduce with my repo, maybe try turning this up higher still.

Tangentially, if you set headless: false a different error appears: [20696:775:0905/140507.299286:ERROR:gpu_process_transport_factory.cc(992)] Lost UI shared context..

I updated the title, description, and the example repo to reflect this new info.

@jessehattabaugh
Copy link
Author

@aslushnikov have you had a chance to checkout my example repo?

@aesnyder
Copy link

I can confirm that I see the unhandled Security.handleCertificateError with headless set to true and slomo at 1000

@aslushnikov
Copy link
Contributor

@jessehattabaugh I didn't figure what to do with your example repository. I'd appreciate if there's a nicer repro, or a step-by-step guide that will help me to reproduce the issue.

Puppeteer v1.0.0 got released recently. Can you please check that the issue still reproes there?

@jessehattabaugh
Copy link
Author

jessehattabaugh commented Jan 19, 2018

@aslushnikov just npm install && npm test it...

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Apr 8, 2018
In certain cases, all callbacks could be rejected before we get a
response from transport. This is easily reproducible with `slowMo`
option.

Fixes puppeteer#563.
aslushnikov added a commit that referenced this issue Apr 8, 2018
…2330)

In certain cases, all callbacks could be rejected before we get a
response from transport. This is easily reproducible with `slowMo`
option.

Fixes #563.
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

3 participants