sails-auth icon indicating copy to clipboard operation
sails-auth copied to clipboard

Sails auth now throwing sails.services.passport.loadStrategies() undefined error.

Open Rohaan-I opened this issue 10 years ago • 36 comments

I was building an app using sailsjs and after week ago it was working fine but right now I'm getting this error. I did'nt change anything. The stacktrace is given below:-

/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails-auth/api/hooks/sails-auth.js:4 sails.services.passport.loadStrategies(); ^ TypeError: Cannot read property 'loadStrategies' of undefined at Hook.initialize (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails-auth/api/hooks/sails-auth.js:4:30) at Hook.bound as initialize at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/lib/hooks/index.js:78:14 at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:451:17 at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:441:17 at _each (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:46:13) at Immediate.taskComplete (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:440:13) at processImmediate as _immediateCallback

Rohaan-I avatar Jul 22 '15 12:07 Rohaan-I

I have just installed and am also getting this error.

peazz avatar Jul 24 '15 14:07 peazz

+1

mkaag avatar Aug 18 '15 12:08 mkaag

+1

sachanganesh avatar Sep 26 '15 01:09 sachanganesh

+1

manuel140 avatar Sep 26 '15 16:09 manuel140

\node_modules\sails-auth\api\hooks\sails-auth.js:4
      sails.services.passport.loadStrategies();
                             ^
TypeError: Cannot read property 'loadStrategies' of undefined
    at Hook.initialize (\node_modules\sails-auth\api\hooks\sails-auth.js:4:30)
    at Hook.bound [as initialize] (\node_modules\lodash\dist\lodash.js:729:21)
    at \node_modules\sails\lib\hooks\index.js:75:14
    at \node_modules\sails\node_modules\async\lib\async.js:451:17
    at \node_modules\sails\node_modules\async\lib\async.js:441:17
    at _each (\node_modules\sails\node_modules\async\lib\async.js:46:13)
    at Immediate.taskComplete (\node_modules\sails\node_modules\async\lib\async.js:440:13)
    at processImmediate [as _immediateCallback] (timers.js:374:17)

+1 happening with sails latest stable

GiantCrocodile avatar Sep 29 '15 14:09 GiantCrocodile

i have the same issue

mariantatarau avatar Sep 29 '15 15:09 mariantatarau

What version of sails are you guys running?

tjwebb avatar Sep 29 '15 19:09 tjwebb

@tjwebb I'm running v0.11.2

My Error Message:

/home/xxx/xxx/node_modules/sails-auth/api/hooks/sails-auth.js:4
      sails.services.passport.loadStrategies();
                             ^
TypeError: Cannot read property 'loadStrategies' of undefined
    at Hook.initialize (/home/xxx/xxx/node_modules/sails-auth/api/hooks/sails-auth.js:4:30)
    at Hook.bound [as initialize] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
    at /usr/local/lib/node_modules/sails/lib/hooks/index.js:75:14
    at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
    at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
    at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
    at Immediate.taskComplete (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

manuel140 avatar Sep 29 '15 19:09 manuel140

Same version as manuel140 on Windows 10 64-bit @tjwebb.

GiantCrocodile avatar Sep 29 '15 20:09 GiantCrocodile

@tjwebb I'm in the same boat; I'm running the same version as manuel140 and GiantCrocodile on Ubuntu.

sachanganesh avatar Sep 29 '15 22:09 sachanganesh

And this is happening on sails-auth 1.3.1?

tjwebb avatar Sep 30 '15 03:09 tjwebb

{ Desktop }  » mkdir test                                                         /cygdrive/c/Users/2c/Desktop
{ Desktop }  » cd test                                                            /cygdrive/c/Users/2c/Desktop
{ test }  » sails new                                                        /cygdrive/c/Users/2c/Desktop/test
info: Created a new Sails app `test`!
{ test }  » sails lift                                                       /cygdrive/c/Users/2c/Desktop/test

info: Starting app...

info:
info:                .-..-.
info:
info:    Sails              <|    .-..-.
info:    v0.11.0             |\
info:                       /|.\
info:                      / || \
info:                    ,'  |'  \
info:                 .-'.-==|/_--'
info:                 `--'-------'
info:    __---___--___---___--___---___--___
info:  ____---___--___---___--___---___--___-__
info:
info: Server lifted in `C:\Users\2c\Desktop\test`
info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.

debug: --------------------------------------------------------
debug: :: Tue Sep 29 2015 22:22:26 GMT-0700 (Pacific Daylight Time)

debug: Environment : development
debug: Port        : 1337
debug: --------------------------------------------------------

{ test }  » npm i sails-auth --save                                      /cygdrive/c/Users/2c/Desktop/test 130
[email protected] node_modules\sails-auth
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
{ test }  » sails lift                                                       /cygdrive/c/Users/2c/Desktop/test

info: Starting app...

C:\Users\2c\Desktop\test\node_modules\sails-auth\api\hooks\sails-auth.js:4
      sails.services.passport.loadStrategies();
                             ^
TypeError: Cannot read property 'loadStrategies' of undefined
    at Hook.initialize (C:\Users\2c\Desktop\test\node_modules\sails-auth\api\hooks\sails-auth.js:4:30)
    at Hook.bound [as initialize] (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\lodash\dist\lodash.js:729:21)
    at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\lib\hooks\index.js:75:14
    at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:451:17
    at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:441:17
    at _each (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:46:13)
    at Immediate.taskComplete (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:440:13)
    at processImmediate [as _immediateCallback] (timers.js:367:17)
{ test }  »                                                                /cygdrive/c/Users/2c/Desktop/test 1

edit: dies on sails 11.2 as well

2c2c avatar Sep 30 '15 05:09 2c2c

:+1: I run into same problem on Sails version: 0.11.2, sails-auth 1.3.1

sunnycmf avatar Oct 03 '15 10:10 sunnycmf

+1

BipinBhandari avatar Oct 04 '15 14:10 BipinBhandari

+1

bmatto avatar Oct 06 '15 19:10 bmatto

I'm running into the same issue. Details of my context:

  • Sails: 0.11.2
  • Sails-auth: 1.3.1

To reproduce the issue:

  • sails new webapp
  • cd webapp
  • npm install sails-auth --save
  • sails lift
info: Starting app...

/home/.../webapp/node_modules/sails-auth/api/hooks/sails-auth.js:4
      sails.services.passport.loadStrategies();
                             ^
TypeError: Cannot read property 'loadStrategies' of undefined
  at Hook.initialize (/home/.../webapp/node_modules/sails-auth/api/hooks/sails-auth.js:4:30)
  at Hook.bound [as initialize] (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
  at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/lib/hooks/index.js:75:14
  at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
  at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
  at _each (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
  at Immediate.taskComplete (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
  at processImmediate [as _immediateCallback] (timers.js:367:17)

ouadi avatar Oct 07 '15 14:10 ouadi

@tjwebb

As you might know, the issue is due to the fact that sails services are loaded after sails hooks in versions 0.11.0 and 0.11.2 that I have tested.

It is more logical that all components of a hook are loaded before the hook itself (which was assumed by the developer of the hook).

ouadi avatar Oct 07 '15 19:10 ouadi

+1

Does anyone have a workaround?

I have the same setup as @ouadi

kddubb avatar Oct 08 '15 21:10 kddubb

It looks like it is a 'hard to solve malfunction': the hook expects that its services have been loaded before it gets loaded itself, which is not the case. In addition, both Sails.js and sails-auth hook are far away from there latest release 1.11.2 and 1.3.1 respectively. So, I expect that the solution from sails.js team will take time.

Till then, I'm using now passport.js directly. People interested in this alternative can find its description here.

ouadi avatar Oct 09 '15 08:10 ouadi

@ouadi yup i also considering to use passports directly, but we may need to glue diff libraries by ourselves and also need to consider when to switch back to sails.

sunnycmf avatar Oct 09 '15 08:10 sunnycmf

I hope that our friends in sails team get quickly a time slot to solve this issue as it is a show stopper for two great extensions: sails-auth and sails-permission. They are doing a great job so far and I'm all hope that they will keep up on the same level of excellence.

ouadi avatar Oct 09 '15 08:10 ouadi

I was just trying to start a fresh project and encountered this (My luck, the day I start...)

While this might not be an acceptable production work around, it got me developing: by uninstalling sails v0.11.2, and reinstalling sails@balderdashy/sails (which installs v12 rc), then in my project specifically installing [email protected]

ghost avatar Oct 17 '15 17:10 ghost

Thanks for the workaround @synaxin

kddubb avatar Oct 19 '15 17:10 kddubb

+1

fredericlefeurmou avatar Oct 24 '15 11:10 fredericlefeurmou

@synaxin :+1:

sunnypatel avatar Nov 21 '15 05:11 sunnypatel

We will try to address this soon. Thank you all for your support.

tjwebb avatar Nov 21 '15 05:11 tjwebb

+1

ronenteva avatar Nov 24 '15 07:11 ronenteva

Not to throw this hardworking team under the bus, do appriciate their work, but I tried Waterlock and it works like a charm!

sunnypatel avatar Nov 24 '15 16:11 sunnypatel

I experienced the same problem. After a bit of googling I found this solution. After editing my package.json and setting the version of sails-auth to 1.2.3 it fixes my problem.

martinbeentjes avatar Dec 11 '15 10:12 martinbeentjes

Another workaround you can try:

Create passport.js file under [project]\api\services and put this code inside: module.exports = require('sails-auth/api/services/passport');

muradaliyev avatar Dec 17 '15 15:12 muradaliyev