Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with "connect-livereload" #14

Closed
tmeani opened this issue May 18, 2014 · 3 comments
Closed

Conflict with "connect-livereload" #14

tmeani opened this issue May 18, 2014 · 3 comments
Labels

Comments

@tmeani
Copy link

tmeani commented May 18, 2014

I'm not too sure why, but cookie-session doesn't work if used after connect-livereload. Let me show you what I mean with a simple example.

This works:

var express = require('express');
var app = express();
var cookieParser = require('cookie-parser');
var session = require('cookie-session');

app.use(cookieParser());
app.use(session({keys: ['mysecret']}));

This instead doesn't work (session values can't be set):

var express = require('express');
var app = express();
var livereload = require('connect-livereload');
var cookieParser = require('cookie-parser');
var session = require('cookie-session');

app.use(livereload());
app.use(cookieParser());
app.use(session({keys: ['mysecret']}));

Any hint where the problem might be?

Thanks!

@pensierinmusica
Copy link

I get the same issue, not sure if the bug is in cookie-session or in connect-livereload. Besides this, it looks like cookie-sessions are generated only after some value is assigned to the session.

Not sure if it's intentional, I'd say it makes sense, although the documentation in readme.md states:

This module provides "guest" sessions, meaning any visitor will have a session, authenticated or not. If a session is new a Set-Cookie will be produced regardless of populating the session.

In particular the part saying "regardless of populating the session" is where I get a bit confused compared to the actual behavior.

Anyways, it'd be great if we could debug the connect-livereload problem first and then see if the two issues are actually related to each other, or completely separate.

@KoryHerzinger
Copy link

For what it's worth, I ran into the same problem recently. It appears that using the connect-livereload middleware before using the session middleware is causing problems:

app.use(require('connect-livereload')());
...
app.use(cookieParser());
app.use(session({
    secret: 'SECRET',
    store: new RedisStore()
}));

By moving the connect-livereload middleware after the session middleware, sessions started working for me again:

app.use(cookieParser());
app.use(session({
    secret: 'SECRET',
    store: new RedisStore()
}));
...
app.use(require('connect-livereload')());

@dougwilson
Copy link
Contributor

This is a bug with connect-livereload. Amny things like this module patches stuff like res.end, but livereload will ruin this: https://github.com/intesso/connect-livereload/blob/v0.4.0/index.js#L94-98

Live reload should not do that restore without being sure that the values it's overwriting is still it's own. Please file bugs at https://github.com/intesso/connect-livereload

@expressjs expressjs locked and limited conversation to collaborators Jun 24, 2014
@expressjs expressjs unlocked this conversation Jun 24, 2014
@expressjs expressjs locked and limited conversation to collaborators Jun 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants