I need to use Network.setRequestInterception while taking a screenshot of webpages
but notice that when I attempt to take a screenshot of a webpage which has a wrong host SSL certificate the script hangs up and times out.
If I remove Network.setRequestInterception the script does not hang up and displays the error below.
Error: net::ERR_CERT_COMMON_NAME_INVALID at https://wrong.host.badssl.com/
Is this a bug? I need to use Network.setRequestInterception to abort some scripts.
Simplified code to illustrate the issue:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await client.send('Network.enable');
await client.send('Network.setRequestInterception', {
patterns: [{ urlPattern: '*' }],
});
await page.goto('https://wrong.host.badssl.com/', {timeout: 0, waitUntil: 'load'});
await page.screenshot({path: 'screenshot/site.png'});
await browser.close();
})();
If you comment out await Network.setRequestInterception the script will run and display an error which is what I want.
Network.setRequestInterception for any URL which contains an invalid or non-existant ssl certificate.