3

Why the error

`Error: The hook 'orm' is taking too long to load.` 

It occurs very often when sails is lifting? Even orm timeout already set to 100000, it still occur sometimes (not always). Usually it happen after PC has been restarted and sails run at first time.

It also often occur at cloud server and my laptop beside my PC. So it occur at my tested environment:

  • Windows 8.1 (PC and laptop) and Linux (Ubuntu 14.04)
  • node.js version 0.10.38
  • sails version 0.11
  • MongoDB version 3

The complete error report is like this

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 [object Object].tooLong [as _onTimeout] (D:\Workspace\Hellowin\cannes\node_modules\sails\lib\app\private\loadHooks.js:92:21)
  at Timer.listOnTimeout [as ontimeout] (timers.js:112:15) { [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)] code: 'E_HOOK_TIMEOUT' }

D:\Workspace\Hellowin\cannes\node_modules\sails\node_modules\async\lib\async.js:30
        if (called) throw new Error("Callback was already called.");
                          ^
Error: Callback was already called.
  at D:\Workspace\Hellowin\cannes\node_modules\sails\node_modules\async\lib\async.js:30:31
  at process._tickDomainCallback (node.js:492:13)

Is it a MongoDB adapter bug?

Rob85
  • 1,719
  • 1
  • 23
  • 46
Andi N. Dirgantara
  • 2,050
  • 13
  • 20
  • Is `mongod` running? Can you access the database through the command prompt? – galactocalypse Jul 30 '15 at 01:26
  • MongoDB running well. I mean, it's often throw an error, not always. So after error, I run again `sails lift` or `node app.js`, sometimes it works sometimes not. Also after I set timeout to 100000, sometimes it still fail. – Andi N. Dirgantara Jul 30 '15 at 01:45
  • 1
    My best guess would be that some other process is hogging your computer's resources. It's plain impossible to continue working with that configuration if a lift fails frequently. You should try freeing your computer's resources. – galactocalypse Jul 30 '15 at 02:08
  • Is that Sails + MongoDB use resource that high? My PC is i3 with RAM 8 GB. – Andi N. Dirgantara Jul 30 '15 at 02:31
  • 1
    Sails + MongoDB isn't high at all. I was talking about "other" processes that "might" be hogging your resources. I use 3 instances of Sails with Mongodb on a laptop with 4GB RAM and can still do a hell lot of other things. See what other processes are consuming your RAM/processor. – galactocalypse Jul 30 '15 at 02:34
  • But why it also occurs may times at my cloud server too? I use Ubuntu 14.04 with 1 CPU and 1 GB RAM. – Andi N. Dirgantara Jul 30 '15 at 03:16
  • 1
    Your database could be too heavy in that case. Does it connect properly if you try using a fresh database? – galactocalypse Jul 30 '15 at 06:42
  • 1
    Also, your `hookTimeout` still shows as 20000. – galactocalypse Jul 30 '15 at 06:51
  • Yes, it's also often throw an error even I drop my whole db (from fresh). As I said, even I change to 100000, it still eventually throw an error. – Andi N. Dirgantara Jul 30 '15 at 06:52
  • hi @AndiN.Dirgantara did you got any solution. I'm also facing the same problem I'm using sails with sequielize with MySQL. It's work fine locally but in the server I'm getting the same error. Did you are using the sequelize with hooks? – Vishnu Mishra Dec 09 '15 at 06:31
  • I don't know exactly is it a bug or something, but I use PM2 then and add timeout a much high value like 100000000. So it has very high timeout and also if it still failed it will restart by PM2. – Andi N. Dirgantara Dec 09 '15 at 06:36

1 Answers1

0

I have encountered the same error recently and found syntax error in one of my model. Now it is working fine. SO basically this error occurs because of some error related to the database. you can check your models, connection, etc..