Skip to content

Sails Sessions with Connect-Redis Work Locally, But Fail When Deployed to Heroku #2379

Closed
@holyxiaoxin

Description

@holyxiaoxin

I've been trying to solve this issue and trying very hard to look for similar problems. But there's only one person experiencing the same problem as me: https://groups.google.com/forum/#!searchin/sailsjs/connect-redis/sailsjs/J0w1O32SHkk/fprYyJYne5QJ

I have tested that if i had installed connect-redis@1.5.0 locally, I can't sails lift. If I had changed to connect-redis@1.4.5 instead, I am able to lift it. Of course, I npm install connect-redis@1.4.5 --save but when I pushed to heroku it throws me the same error I would received as though I had installed the v1.5.0.

Nov 07 08:54:38 sails-wusrs heroku/slug-compiler:  Slug compilation started 
Nov 07 08:54:50 sails-wusrs heroku/slug-compiler:  Slug compilation finished 
Nov 07 08:54:50 sails-wusrs heroku/web.1:  State changed from crashed to starting 
Nov 07 08:54:55 sails-wusrs heroku/web.1:  Starting process with command `NODE_ENV=production node app.js` 
Nov 07 08:54:58 sails-wusrs app/web.1:  Could not load Connect session adapter :: connect-redis 
Nov 07 08:54:58 sails-wusrs app/web.1:  A hook (`session`) failed to load! 
Nov 07 08:54:58 sails-wusrs app/web.1:  Error from adapter: 
Nov 07 08:54:58 sails-wusrs app/web.1:  TypeError: Cannot read property 'prototype' of undefined 
Nov 07 08:54:58 sails-wusrs app/web.1:      at module.exports (/app/node_modules/connect-redis/lib/connect-redis.js:96:41) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Hook.Session.initialize (/app/node_modules/sails/lib/hooks/session/index.js:204:33) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Hook.bound [as initialize] (/app/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/lib/hooks/index.js:132:16 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/node_modules/async/lib/async.js:425:17 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/node_modules/async/lib/async.js:419:17 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Array.forEach (native) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at _each (/app/node_modules/sails/node_modules/async/lib/async.js:32:24) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Object.taskComplete (/app/node_modules/sails/node_modules/async/lib/async.js:418:13) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at processImmediate [as _immediateCallback] (timers.js:345:15) 
Nov 07 08:54:58 sails-wusrs app/web.1:  Do you have the Connect session adapter installed in this project? 
Nov 07 08:54:58 sails-wusrs app/web.1:  Try running the following command in your project's root directory: 
Nov 07 08:54:58 sails-wusrs app/web.1:  npm install connect-redis@1.4.5 
Nov 07 08:54:58 sails-wusrs app/web.1:  (Note that `connect-redis@1.5.0` introduced breaking changes- make sure you have v1.4.5 installed!) 
Nov 07 08:54:58 sails-wusrs app/web.1:  Could not load Connect session adapter :: connect-redis 
Nov 07 08:54:58 sails-wusrs app/web.1:  Error from adapter: 
Nov 07 08:54:58 sails-wusrs app/web.1:  TypeError: Cannot read property 'prototype' of undefined 
Nov 07 08:54:58 sails-wusrs app/web.1:      at module.exports (/app/node_modules/connect-redis/lib/connect-redis.js:96:41) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Hook.Session.initialize (/app/node_modules/sails/lib/hooks/session/index.js:204:33) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Hook.bound [as initialize] (/app/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/lib/hooks/index.js:132:16 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/node_modules/async/lib/async.js:425:17 
Nov 07 08:54:58 sails-wusrs app/web.1:      at /app/node_modules/sails/node_modules/async/lib/async.js:419:17 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Array.forEach (native) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at _each (/app/node_modules/sails/node_modules/async/lib/async.js:32:24) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at Object.taskComplete (/app/node_modules/sails/node_modules/async/lib/async.js:418:13) 
Nov 07 08:54:58 sails-wusrs app/web.1:      at processImmediate [as _immediateCallback] (timers.js:345:15) 
Nov 07 08:54:58 sails-wusrs app/web.1:  Do you have the Connect session adapter installed in this project? 
Nov 07 08:54:58 sails-wusrs app/web.1:  Try running the following command in your project's root directory: 
Nov 07 08:54:58 sails-wusrs app/web.1:  npm install connect-redis@1.4.5 
Nov 07 08:54:58 sails-wusrs app/web.1:  (Note that `connect-redis@1.5.0` introduced breaking changes- make sure you have v1.4.5 installed!) 
Nov 07 08:55:55 sails-wusrs heroku/web.1:  Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
Nov 07 08:55:55 sails-wusrs heroku/web.1:  Stopping process with SIGKILL 
Nov 07 08:55:56 sails-wusrs heroku/web.1:  State changed from starting to crashed

I can't understand why is this happening. ): Is this something to do with heroku or sailsjs? Please help me. I'm quite desperate.

Activity

holyxiaoxin

holyxiaoxin commented on Nov 9, 2014

@holyxiaoxin
Author

This issue is resolved by removing the ^ inside "^1.4.5". instead it'll look like this: "1.4.5"

sailsjs does not work with connect-redis@1.5.0 and strictly needs only @1.4.5 and below. upgrading the package will cause heroku to crash. removing ^ means that it'll only use version 1.4.5.

zacharygcook

zacharygcook commented on Jul 8, 2015

@zacharygcook

Thanks this helped me out a ton!

jury89

jury89 commented on Feb 4, 2016

@jury89

thank, you saved my day 👍

dspencerr

dspencerr commented on Feb 6, 2016

@dspencerr

amazing that they still have done nothing with this. Thanks so much!

mikermcneil

mikermcneil commented on Feb 9, 2016

@mikermcneil
Member

We've spent quite a lot of time working on a better way to address this type of issue for dependencies you install in your app in general. Eventually for this particular case, I added a warning in the session hook that suggests changing the version of connect redis if an error occurs. But that was before the version of npm that generated carets instead of tildas from --save was widely used.

At the end of the day, the main issue here is with documentation. But I agree that more could still be done-- open to ideas.

Reopening this until we get the sails.config.session reference doc page and "scaling" conceptual doc page updated to specifically mention installing and pinning the 1.4.5 dependency.

sgress454

sgress454 commented on Feb 10, 2016

@sgress454
Member

This should no longer be an issue with Sails v0.11.4+ and v0.12.x (that is, you should be able to use the newest connect-redis). The problem was that newer versions of connect-redis are initialized using express-session, while older ones simply use express. We now support both.

mikermcneil

mikermcneil commented on Feb 10, 2016

@mikermcneil
Member

@dspencerr @jury89 would you guys try this out for us?

mikermcneil

mikermcneil commented on Feb 11, 2016

@mikermcneil
Member

@dspencerr @jury89 @holyxiaoxin @djlovegrind Here's a preview of the updated docs that use --save-exact so that you end up with a pinned dependency in your app.

Please open a new issue if you see any problems with this going forward. The relevant docs will be online sometime this week when we release the next patch for sails core. Thanks y'all!

tarunjadhwani

tarunjadhwani commented on Apr 14, 2016

@tarunjadhwani

Wait so should we downgrade connect-redis to 1.4.5? Because I'm using sails 0.12.1 and still facing this issue with connect-redis version 3.0.2?

sijojlouis

sijojlouis commented on May 8, 2016

@sijojlouis

+1

alexsalesdev

alexsalesdev commented on Jun 21, 2017

@alexsalesdev

+1

Fr33maan

Fr33maan commented on Oct 20, 2017

@Fr33maan

@mikermcneil @sgress454 broken when connect-redis@3, working when downgrading to 1.4.5.
@sgress454 Does sails 0.12.x should support connect-redis^3 ?
I've got another error:

connected
verbose: A socket is being allowed to connect, but the session could not be loaded.  Will create an empty, one-time session to use for the life of the socket connection.  Details:
 Error: Session could not be loaded
    at _createError (/home/l1br3/dev/App/node_modules/sails/lib/hooks/session/index.js:31:19)
    at /home/l1br3/dev/App/node_modules/sails/lib/hooks/session/index.js:34:11
    at Command.callback (/home/l1br3/dev/App/node_modules/connect-redis/lib/connect-redis.js:155:25)
    at normal_reply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:726:21)
    at RedisClient.return_reply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:824:9)
    at JavascriptRedisParser.returnReply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:192:18)
    at JavascriptRedisParser.execute (/home/l1br3/dev/App/node_modules/redis-parser/lib/parser.js:574:12)
    at Socket.<anonymous> (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:274:27)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at TCP.onread (net.js:563:20)
verbose: Receiving incoming message from Socket.io:  { method: 'get',
  headers: { authorization: 'Bearer secret_user_token' },
  data: {},
  url: '/register_ws' }
verbose: Interpreting socket.io message as virtual request to "get /register_ws"...
req.socketId: SVaupw01oUvrxQ4NAAAA
verbose: Lowering sails...
verbose: Sent kill signal to child process (5125)...
^C
l1br3@l1br3:~/dev/App$ verbose: Shutting down HTTP server...
warn: Socket disconnected, but session could not be loaded to pass to configured disconnect handler: `sails.config.sockets.afterDisconnect()`.  Will pass a fake, empty session as argument to lifecycle callback.  Details:
 Error: Session could not be loaded
    at _createError (/home/l1br3/dev/App/node_modules/sails/lib/hooks/session/index.js:31:19)
    at /home/l1br3/dev/App/node_modules/sails/lib/hooks/session/index.js:34:11
    at Command.callback (/home/l1br3/dev/App/node_modules/connect-redis/lib/connect-redis.js:155:25)
    at normal_reply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:726:21)
    at RedisClient.return_reply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:824:9)
    at JavascriptRedisParser.returnReply (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:192:18)
    at JavascriptRedisParser.execute (/home/l1br3/dev/App/node_modules/redis-parser/lib/parser.js:574:12)
    at Socket.<anonymous> (/home/l1br3/dev/App/node_modules/connect-redis/node_modules/redis/index.js:274:27)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at TCP.onread (net.js:563:20)
disconnected


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sgress454@mikermcneil@jury89@dspencerr@Fr33maan

        Issue actions

          Sails Sessions with Connect-Redis Work Locally, But Fail When Deployed to Heroku · Issue #2379 · balderdashy/sails