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

Failed the minimize CSS: Error: Protocol error (Emulation.setDeviceMetricsOverride) #340

Open
homanp opened this issue Nov 8, 2019 · 1 comment

Comments

@homanp
Copy link

homanp commented Nov 8, 2019

Hi there @peterbe!

I'm trying to use your module with my own instance of puppeteer. My code looks like so:

'use strict'
const chrome = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');
const miminalcss = require('minimalcss');

const url = 'https://www.google.com';
let minimalCss = '';

const browser = await puppeteer.launch({
	args: chrome.args,
	executablePath: await chrome.executablePath,
	headless: chrome.headless
});
 
miminalcss.minimize({urls: [url], browser})
	.then(result => {
		minimalCss = result.finalCss;
	})
	.catch(error => {
		console.error(`Failed the minimize CSS: ${error}`);
	});

ERROR:
RROR Failed the minimize CSS: Error: Protocol error (Emulation.setDeviceMetricsOverride): Session closed. Most likely the page has been closed.

DEPENDENCIES:

"chrome-aws-lambda": "^2.0.0",
"minimalcss": "^0.8.3",
"puppeteer-core": "^2.0.0",

Any ideas on what the issue might be? Seems like the connection is getting closed for some reason.

Thanks!

@peterbe
Copy link
Owner

peterbe commented Jan 23, 2020

I don't know how I didn't see this until now!
To be honest, I actually don't know how to debug this. I tried to edit your demo code by switching from puppeteer-core to puppeteer but I keep getting this:

▶ node index.js
Failed the minimize CSS: Error: DOMException: A network error occurred.

A Chromium window does appear with nothing in the Web console.
Screen Shot 2020-01-23 at 12 55 47 PM

Perhaps a bunch of dependencies have changed enough to not be able to reproduce.
Perhaps I just don't understand how to use chrome-aws-lambda and puppeteer-core.
Perhaps you can injects some debugging and try to understand why it's throwing like that.

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