Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the hook orm taking too long to load

Tags:

sails.js

i am using two database adapters with sails.

one for mondoDB and second for mysql.whenever i run command "sails lift".once it gives an error

error: Error: The hook `orm` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or else set       `sails.config.orm._hookTimeout to a higher value (currently 20000)
at tooLong [as _onTimeout]   (C:\Users\KAMI\AppData\Roaming\npm\node_modules\sails\lib\app\private\loadHooks.js:92:21)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15

when i rerun sails without changes it gives no error then.how can i avoid this error everytime.this is my 1st experience with sailsjs so any help will be apreciated....

like image 826
N.A Avatar asked Feb 15 '15 09:02

N.A


3 Answers

I ran into this problem last night because of a slow internet connection between my laptop and the DB server. My solution was to create a new file in the config directory called orm.js (name doesn't really matter).

Then add the following code:

// config/orm.js
module.exports.orm = {
  _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

I also found I had to change my pubsub timeout but that may not be necessary for you.

// config/pubsub.js
module.exports.pubsub = {
  _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

Note: The other answer recommends changing the sails files inside the node_modules folder. This is almost always a bad idea because any npm update could revert your changes.

like image 65
davepreston Avatar answered Nov 12 '22 00:11

davepreston


It is likely best to do this on a per env basis. Under config directory, you will have something like:

env path

Then enter, inside module.exports of each:

module.exports = {

  hookTimeout: 40000

}

Notice, there is no need for an underscore in front of the attribute name either.

like image 23
arcseldon Avatar answered Nov 12 '22 01:11

arcseldon


I realise this is quite an old question, but I also had the same problem. I was convinced it wasn't my connection.

My solution is to change your migration option for your models and you'll have a choice of 3

  1. safe - never auto-migrate my database(s). I will do it myself (by hand)
  2. alter - auto-migrate, but attempt to keep my existing data (experimental)
  3. drop - wipe/drop ALL my data and rebuild models every time I lift Sails

Got to config/models.js and in there put:

migrate: 'safe'

or whatever option from above you want to use.

like image 10
K20GH Avatar answered Nov 11 '22 23:11

K20GH