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

Unhandled exception breaks down grunt task #213

Closed
shervud opened this issue Dec 13, 2017 · 13 comments
Closed

Unhandled exception breaks down grunt task #213

shervud opened this issue Dec 13, 2017 · 13 comments

Comments

@shervud
Copy link

shervud commented Dec 13, 2017

Hi colleagues.
I faced with unknown problem. I cannot reproduce, resolve and handle that problem. I have written that problem here gruntjs/grunt#1614

In case when I make 100 similar runs of grunt-critical task, sometime and randomly grunt can be crushed and I do not have ideas why.

I use all the tasks with --force. And it seems that sometime it is handled as OK, and sometime NOT.
Take a look at these screenshots:

There is a fail:
grunt-task-fails-2

And there is no fail:
grunt-task-fails-3

Can you assume where the problem begins in penthouse side or Node.js side, or in grunt side?
Thank you all.

@pocketjoso
Copy link
Owner

@shervud to begin with, can you check what Penthouse version you have installed locally? I.e. the one in your node_modules, what version is it?

@pocketjoso
Copy link
Owner

I suspect that it's quite an old version, and then these problems are likely to go away on the latest version (1.2.0)

@shervud
Copy link
Author

shervud commented Dec 13, 2017

Thank you for the quick response.
I use grunt-critical 1.1.0, which uses critical 1.1.0, which uses penthouse 1.0.0 (seems so). Here is a content of package.json of penthouse:
"_from": "penthouse@^1.0.0",
"_id": "[email protected]"

Anyway... How is it possible that for example I ran 100 times grunt task to create critical.css from url http://example.com and randomly it may be crushed (suppose on 70 of 100 run).
Also I noticed the errors in grunt-critical 0.3.0, which uses penthouse 0.11.13.

@shervud
Copy link
Author

shervud commented Dec 13, 2017

Theoretically, even if penthouse has error , does not grunt successfully handle that error if --force option is provided?

@pocketjoso
Copy link
Owner

In general, a timeout means your page didn't load. A crash can mean that you we're running out of memory on the machine you were running this on.

Are you starting 100 penthouse job in parallel? That essentially means opening up a 100 browser tabs, which would not surprise me if it crashes. Try limiting the number of jobs you run in parallel and hopefully that will resolve the errors. I personally run about 4-5 in parallel, but it depends on your machine.

@shervud
Copy link
Author

shervud commented Dec 14, 2017

Arrr, karrrramba!!!))
Pockejoso, noo way! Are you sure about me, that I run 100 in parallel?
I said, that I am running for example 100 times consequently in loop, not in parallel.
So only 1 penthouse job is run at the same time.
Or for better example - I have only 1 task and run it manually by typing "grunt myTask". And I can repeat in 40 times, but once it may be crash. So there are no parallel processes

@shervud
Copy link
Author

shervud commented Dec 14, 2017

It would be rather look like error on Node side, i don't know...
Having the fact I request penthouse by running grunt-critical, may be you know the answer better than me -
Shouldn't grunt option --force preserve the whole process in such kind of situations like that? I mean, if there is even Unhandled error exists in pentouse?
If so, it seems like the problem is in Nodejs side, kinda the process fails and i should catch it manually

@pocketjoso
Copy link
Owner

Pockejoso, noo way! Are you sure about me, that I run 100 in parallel?

Sorry I wasn't sure, it was just a suggestion, but okay then I know that's not the case.

Penthouse does indeed throw after a certain timeout has been reached. The default timeout value is 30s, and this can be changed in the Penthouse options, see the readme here:
https://github.com/pocketjoso/penthouse#as-a-node-module
Perhaps this error is not caught in critical?

You might want to debug why your site is taking over 30s to load occasionally. Are you hitting a live site over http, or a local html file?

@shervud
Copy link
Author

shervud commented Jan 8, 2018

Hello. Sorry for the delay.
I'm opening a live site over https. But it fails randomly, sometime it is ok, sometime it's not.
Here one more screenshot.

image

@shervud
Copy link
Author

shervud commented Jan 8, 2018

Is there a way to workaround this issue? May be by try/catch grunt fail in Node.js process ?
Or may be is there any --verbose option. Like there gruntjs/grunt-contrib-imagemin#93 ?

@pocketjoso
Copy link
Owner

For getting verbose output, see the debugging section in readme:
https://github.com/pocketjoso/penthouse#enable-debug-logging

If you could paste the output here, then we can see how far your critical css generation gets for the jobs where you have this issue.


Other than this I just saw a comment on the critical library (which is built on top of penthouse), from a user saying that they were able to fix this issue via downgrading the ws library - perhaps check out and test?
addyosmani/critical#181 (comment)

@shervud
Copy link
Author

shervud commented Jan 20, 2018

Yeah, it helped me. Thank you a lot!

Quite strange, for sure. But the problem was in ws package. It had been upgraded from 3.3.2 to 3.3.3 at December 2017. So after I downgraded and locked ws to 3.3.2, it started to work.
Cool

@shervud shervud closed this as completed Jan 20, 2018
@pocketjoso
Copy link
Owner

Glad to hear it worked for you!

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