pocketjoso / penthouse

Generate critical css for your web pages
https://jonassebastianohlsson.com/criticalpathcssgenerator
MIT License
2.64k stars 164 forks source link

UnhandledPromiseRejectionWarning: Page crashed #220

Closed srtfisher closed 6 years ago

srtfisher commented 6 years ago

Seeing an issue when running Penthouse:

penthouse new browser launched +393ms
penthouse parsed ast (with 0 errors) +40ms
penthouse parsed ast (with 0 errors) +0ms
penthouse parsed ast (with 0 errors) +0ms
penthouse parsed ast (with 0 errors) +0ms
penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +0ms
penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: {
penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen",
penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px",
penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px"
penthouse:preformatting:nonMatchingMediaQueryRemover } +1ms
penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +30ms
penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms
penthouse stripped out non matching media queries +79ms
penthouse call generateCriticalCssWrapped +1ms
penthouse adding browser page for generateCriticalCss, now: 1 +0ms
penthouse:core Penthouse core start +0ms
penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +10ms
penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: {
penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen",
penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px",
penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px"
penthouse:preformatting:nonMatchingMediaQueryRemover } +0ms
penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +6ms
penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms
penthouse stripped out non matching media queries +76ms
penthouse call generateCriticalCssWrapped +1ms
penthouse adding browser page for generateCriticalCss, now: 2 +0ms
penthouse:core Penthouse core start +15ms
penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +7ms
penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: {
penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen",
penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px",
penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px"
penthouse:preformatting:nonMatchingMediaQueryRemover } +0ms
penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +28ms
penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +1ms
penthouse stripped out non matching media queries +104ms
penthouse call generateCriticalCssWrapped +0ms
penthouse adding browser page for generateCriticalCss, now: 3 +0ms
penthouse:core Penthouse core start +35ms
penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +3ms
penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: {
penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen",
penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px",
penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px"
penthouse:preformatting:nonMatchingMediaQueryRemover } +1ms
penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +4ms
penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms
penthouse stripped out non matching media queries +101ms
penthouse call generateCriticalCssWrapped +0ms
penthouse adding browser page for generateCriticalCss, now: 4 +0ms
penthouse:core Penthouse core start +8ms
penthouse:core new page opened in browser +27ms
penthouse:core new page opened in browser +1ms
penthouse:core viewport set +3ms
penthouse:core viewport set +2ms
penthouse:core blocking js requests +6ms
penthouse:core page load start +0ms
penthouse:core blocking js requests +1ms
penthouse:core page load start +0ms
penthouse:core new page opened in browser +13ms
penthouse:core viewport set +1ms
penthouse:core blocking js requests +3ms
penthouse:core page load start +0ms
penthouse:core new page opened in browser +3ms
penthouse:core viewport set +2ms
penthouse:core blocking js requests +2ms
penthouse:core page load start +0ms
penthouse:core page load DONE +871ms
penthouse:core added css-tree library to page +7ms
penthouse:core page load DONE +304ms
penthouse:core added css-tree library to page +3ms
penthouse:core page load DONE +209ms
penthouse:core added css-tree library to page +5ms
penthouse:core pruneNonCriticalCss +101ms
(node:467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Page crashed!

Any ideas what could be going on?

pocketjoso commented 6 years ago

Did you run out of memory on the machine? How many penthouse job were you running simultaneously? You could try running one at a time and see if that resolves this issue for you.

Le 21 déc. 2017 20:29, "Sean Fisher" notifications@github.com a écrit :

Seeing an issue when running Penthouse:

penthouse new browser launched +393ms penthouse parsed ast (with 0 errors) +40ms penthouse parsed ast (with 0 errors) +0ms penthouse parsed ast (with 0 errors) +0ms penthouse parsed ast (with 0 errors) +0ms penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +0ms penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: { penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen", penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px", penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px" penthouse:preformatting:nonMatchingMediaQueryRemover } +1ms penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +30ms penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms penthouse stripped out non matching media queries +79ms penthouse call generateCriticalCssWrapped +1ms penthouse adding browser page for generateCriticalCss, now: 1 +0ms penthouse:core Penthouse core start +0ms penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +10ms penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: { penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen", penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px", penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px" penthouse:preformatting:nonMatchingMediaQueryRemover } +0ms penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +6ms penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms penthouse stripped out non matching media queries +76ms penthouse call generateCriticalCssWrapped +1ms penthouse adding browser page for generateCriticalCss, now: 2 +0ms penthouse:core Penthouse core start +15ms penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +7ms penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: { penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen", penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px", penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px" penthouse:preformatting:nonMatchingMediaQueryRemover } +0ms penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +28ms penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +1ms penthouse stripped out non matching media queries +104ms penthouse call generateCriticalCssWrapped +0ms penthouse adding browser page for generateCriticalCss, now: 3 +0ms penthouse:core Penthouse core start +35ms penthouse:preformatting:nonMatchingMediaQueryRemover BEFORE +3ms penthouse:preformatting:nonMatchingMediaQueryRemover matchConfig: { penthouse:preformatting:nonMatchingMediaQueryRemover "type": "screen", penthouse:preformatting:nonMatchingMediaQueryRemover "width": "1300px", penthouse:preformatting:nonMatchingMediaQueryRemover "height": "960px" penthouse:preformatting:nonMatchingMediaQueryRemover } +1ms penthouse:preformatting:nonMatchingMediaQueryRemover DROP: ((min-width:92em)), +4ms penthouse:preformatting:nonMatchingMediaQueryRemover AFTER +0ms penthouse stripped out non matching media queries +101ms penthouse call generateCriticalCssWrapped +0ms penthouse adding browser page for generateCriticalCss, now: 4 +0ms penthouse:core Penthouse core start +8ms penthouse:core new page opened in browser +27ms penthouse:core new page opened in browser +1ms penthouse:core viewport set +3ms penthouse:core viewport set +2ms penthouse:core blocking js requests +6ms penthouse:core page load start +0ms penthouse:core blocking js requests +1ms penthouse:core page load start +0ms penthouse:core new page opened in browser +13ms penthouse:core viewport set +1ms penthouse:core blocking js requests +3ms penthouse:core page load start +0ms penthouse:core new page opened in browser +3ms penthouse:core viewport set +2ms penthouse:core blocking js requests +2ms penthouse:core page load start +0ms penthouse:core page load DONE +871ms penthouse:core added css-tree library to page +7ms penthouse:core page load DONE +304ms penthouse:core added css-tree library to page +3ms penthouse:core page load DONE +209ms penthouse:core added css-tree library to page +5ms penthouse:core pruneNonCriticalCss +101ms (node:467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Page crashed!

Any ideas what could be going on?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pocketjoso/penthouse/issues/220, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3BAGppm5bPIuJYvBWaqSKG_PCbPgVCks5tCrGtgaJpZM4RKQLH .

ValentinFunk commented 6 years ago

If you run in docker make sure /dev/shm is large

shervud commented 6 years ago

Hi, fellows! Have the same issue and seems like I detected the root cause, but still have no competency to solve it. I use grunt-critical (which uses Penthouse). Several of our sites are hosted on a hosting which is designed special for Drupal sites and most of sites use CDN (CloudFlare). So seems like our "special hosting" has firewalls and etc... + CloudFlare of course has it ;) I mean, you know when you are trying to open some site which is covered by CDN, and you are seeing page with Google captcha in order to detect you are not a robot.

So these sites absolutely randomly meet the errors like these:

`Unhandled Rejection at: Promise {

Error: Protocol error (Runtime.evaluate): Session closed. Most likely the page has been closed. at Session.send (***/node_modules/puppeteer/lib/Connection.js:167:29) at ExecutionContext.evaluateHandle (***/node_modules/puppeteer/lib/ExecutionContext.js:52:77) at ExecutionContext.evaluate (***/node_modules/puppeteer/lib/ExecutionContext.js:37:31) at Frame.evaluate (***/node_modules/puppeteer/lib/FrameManager.js:211:26) at Page.evaluate (***/node_modules/puppeteer/lib/Page.js:582:43) at ***/node_modules/penthouse/lib/core.js:146:18 at } ` or `Unhandled Rejection at: Promise { Error: Page crashed! at Page._onTargetCrashed (***/node_modules/puppeteer/lib/Page.js:97:24) at Session.Page.client.on.event (***/node_modules/puppeteer/lib/Page.js:92:56) at emitOne (events.js:125:13) at Session.emit (events.js:221:7) at Session._onMessage (***/node_modules/puppeteer/lib/Connection.js:199:12) at Connection._onMessage (***/node_modules/puppeteer/lib/Connection.js:98:19) at emitOne (events.js:125:13) at WebSocket.emit (events.js:221:7) at Receiver._receiver.onmessage (***/node_modules/ws/lib/WebSocket.js:143:47) at Receiver.dataMessage (***/node_modules/ws/lib/Receiver.js:389:14) at Receiver.getData (***/node_modules/ws/lib/Receiver.js:330:12) at Receiver.startLoop (***/node_modules/ws/lib/Receiver.js:165:16) at Receiver.add (***/node_modules/ws/lib/Receiver.js:139:10) at Socket._ultron.on (***/node_modules/ws/lib/WebSocket.js:139:22) at emitOne (events.js:125:13) at Socket.emit (events.js:221:7) at addChunk (_stream_readable.js:265:12) at readableAddChunk (_stream_readable.js:252:11) at Socket.Readable.push (_stream_readable.js:209:10) at TCP.onread (net.js:598:20) } ` However, I tried to make some testings on my personal sites and on several regional large news portals which do not use any firewalls and CloudFlare (do not use any CDN). In that case the errors have never been! **How I test:** 1. Sites on a special hosting + CDN. In that case the error can appear randomly, even if there is only one URL and one request (not a bunch of URLs in an array/queue), so right at 1st URL. 2. My personal sites and a regional large news portal. In that case errors have never been seem, even if I use bunch of URLs (home pages and inner pages both) and have a set of 100-200 URLs per one test (foreach form 100-200 urls)
shervud commented 6 years ago

@srtfisher , what is the way and platform you are running penthouse in? MacOS, Ubuntu, Vagrant or Docker? Seems like I found the cause (for Docker case). Local in Windows 10 and under Vagrant (with Ubuntu 14 x64) it is always fine for me, whereas our project is in Docker and it is always f..cking random failures there (page crashed, session closed, etc...).

The same issues and complaints were found a lot of where: https://github.com/GoogleChrome/puppeteer/issues/1321 https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker https://bugs.chromium.org/p/chromium/issues/detail?id=736452 https://bugs.chromium.org/p/chromium/issues/detail?id=715363 https://github.com/c0b/chrome-in-docker/issues/1

Result: I have increased the RAM of my Docker container and now there are no any random errors.

pocketjoso commented 6 years ago

Seems like this was about insufficient memory allocated for penthouse/chrome, on the machine. Will close the issue, for now.

Will re-open if someone comments, if the problem still exists and memory doesn't explain it - please test on the latest version of Penthouse first though!