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

Some https requests are not intercepted #2111

Closed
Madd0g opened this issue Feb 27, 2018 · 3 comments
Closed

Some https requests are not intercepted #2111

Madd0g opened this issue Feb 27, 2018 · 3 comments

Comments

@Madd0g
Copy link

Madd0g commented Feb 27, 2018

Steps to reproduce

I've seen it multiple times and found good public repro url, on wikipedia there's no request/response event for the main logo, it's an image referenced by a stylesheet and it never shows up in either page.on('request') or page.on('response'). For me it happens more often with SSL resources.

url that doesn't show up: https://en.wikipedia.org/static/images/project-logos/enwiki-2x.png

code that references it:

background-image: url(/static/images/project-logos/enwiki-2x.png);

Tell us about your environment:

What steps will reproduce the problem?

Please include code that reproduces the issue.

const puppeteer = require('puppeteer')

const url = 'https://en.wikipedia.org/wiki/Lion';

const run = async (browser) => {
	const page = await browser.newPage()
	page.setRequestInterceptionEnabled(true) 
	
	page.on('request', request => {
		console.log("REQUEST TO : " + request.url);
		request.continue(); // pass it through.
	});

	page.on('response', response => {
		const req = response.request(); 
		console.log(req.method, response.status, req.url);
	});
		
	await page.goto(url); 
}

(async () => {
  const browser = await puppeteer.launch({headless: false})
  await run(browser);
})();

What is the expected result?
Expect to see https://en.wikipedia.org/static/images/project-logos/enwiki-2x.png as one of the requests from the page (the image shows up in the browser and the request is visible in the native devtools)

What happens instead?
There's no event for it.

@ebidel
Copy link
Contributor

ebidel commented Feb 27, 2018

This is somewhat related to #1910.

Puppeteer emulates a 800x600 mobile viewport by default with a DPR of 1.0. When you load https://en.wikipedia.org/wiki/Lion in chrome and emulate that device, you'll see that enwiki-2x.png doesn't load.

You'll need to emulate a DPR of 2 for their responsive CSS to load the image:

await page.setViewport({width: 800, height: 600, deviceScaleFactor: 2});

BTW, your code doesn't look like pptr v1.1.0. setRequestInterceptionEnabled was renamed to setRequestInterception a while ago and request/response.url are not methods.

@ebidel ebidel closed this as completed Feb 27, 2018
@Madd0g
Copy link
Author

Madd0g commented Feb 27, 2018

@ebidel - thank you, adding deviceScaleFactor: 2 does solve this problem.

Sorry about the code example, I do use 1.1.0 but I copied the example from another issue here and failed to notice that it was the older syntax.

Is this issue related to the headless setting? I know for sure that when it was happening I changed the headless setting to false and inspected the image/network and saw the correct enwiki-2x.png appear.

@ebidel
Copy link
Contributor

ebidel commented Feb 27, 2018

I don't see enwiki-2x.png load when I run your script in headful mode.

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

2 participants