Hi There,
I have Sails 0.11 framework. Add some additional code. Currently I have only one controller without model to it. Added MongoDB connection in config/connections.js and set it up in config/modes.js. I am using UBUNTU 14 machine. All is fine when sails lift is done. However, as long as I type sails lift --prod I have got the error below:
error: Error: The hook `grunt` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
at tooLong [as _onTimeout] (/usr/lib/node_modules/sails/lib/app/private/loadHooks.js:92:21)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
I have two questions:
sails.config.grunt._hookTimeout parameter? If it is assumed to be in config/grunt.js file I do not have this one in my config folder.Best Regards,
Angel
I have just found out that the issue is caused from angular.js file. When the file is in /assets/js/dependencies folder it appears that Grunt is not able to minify / uglify it. The same goes even if I changed angular.js to angular.min.js. The angular.min.js is about 125K and it seems too big for Grunt. If this is the case, how to solve it?
hey @angel1st you can solve this by setting the hookTimeout config. We're planning on dramatically increasing the default in the next version because it's super annoying when this happens- sorry about that. cc @sgress454
@angel1st in the meantime you can set sails.config.hookTimeout to change the global hook timeout--for example in config/locals.js:
module.exports = {
hookTimeout: 30000, // 30 seconds
...other config...
}
@mikermcneil & @sgress454 thanks for the feedback and the tip guys. Cheers!
The change worked of us in production. Tks!
:+1: please increase the default value!
@mikermcneil Where can I set the hookTimeout config to fix this?
any update?
Have the same issue when pushing to heroku, tried the fix suggested by @sgress454 but still fails.
@RaedsLab try the fix suggested here for Heroku. It moves the Grunt tasks into the Heroku app startup phase, rather than having them occur during sails lift.
@sgress454 Thank you this solved it
I had a similar message but for sails.config.logger._hookTimeout for a sync service that necessarily takes too long to load.
My suggestion would be to set a higher value on my own code before it starts loading.
sails.config.logger._hookTimeout = myHigherValue;
and perhaps reset it after loading.
However:
hookTimeout not _hookTimeoutlog instead of logger?EDIT
Sorry folks, I wrote before actually checking the sails.config object and there is a sails.config.hooks.logger
I encountered the same issue as the author of the first comment. But what is strange in my situation is that the issue occurs _only_ when sails is lifted with the --prod flag, _even though_ the grunt tasks are _identical_ both for prod and default modes (I just copy-pasted) tasks from tasks/register/default.js to tasks/register/prod.js.
Before I had _hookTimeout set to 40000. Now increased to 90000, but the problem is still there. So what is the difference for grunt between prod and dev modes beyond tasks lists?
UPDATE (and explanation of the issue' origins)
Checked out the grunt hook to understand what happens. And it turns out that in default mode the grunt hook triggers callback right after grunt has started, but for the prod mode it is triggered when grunt has finished. So if there is anything watching (like using watch in browserify) in prod, grunt task will never exit, and therefore grunt hook will always timeout.
Since modifying the original grunt hook is not the best idea (it lives in node_modules), the best is indeed to increase the _hookTimeout option (yes, underscore is there, that's correct) and to make sure grunt task exits (for this it can be run separately with grunt prod)
With prod all your js is minified and uglified.
It's not good to run grunt in production. You should look to use the build
www to statically build these for deployment and leave grunt disabled in
prod
On Wed, Aug 17, 2016 at 12:54 PM amberv0 [email protected] wrote:
I encountered the same issue. But what is strange for me is that it occurs
_only_ when sails is lifted with the --prod flag, even though the grunt
tasks are _identical_ both for prod and default modes (I just
copy-pasted) tasks from tasks/register/default.js to
tasks/register/prod.js.
Before I had _hookTimeout equal set to 40000. Now increased to 90000, but
the problem is still there. So what is the difference for grunt between
prod and dev modes beyond tasks lists?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/balderdashy/sails/issues/2691#issuecomment-240475135,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACsR6Gf1mkyJuy4SQKGVX55w50SqBtZ3ks5qgzyxgaJpZM4DlfPt
.
Most helpful comment
@angel1st in the meantime you can set
sails.config.hookTimeoutto change the global hook timeout--for example inconfig/locals.js: