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

Unknown Windows/connect-mongo bug #224

Closed
ghost opened this issue Mar 18, 2015 · 5 comments
Closed

Unknown Windows/connect-mongo bug #224

ghost opened this issue Mar 18, 2015 · 5 comments
Labels
type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.

Comments

@ghost
Copy link

ghost commented Mar 18, 2015

When running the gulp command, the browser launches and I get an error:

500 Error: Error getting collection: sessions
at \freecodecamp\node_modules\connect-mongo\lib\connect-mongo.js:160:19

Refreshing "fixes" the problem. If gulp auto reloads the project it's also fine. If I rerun the "gulp" command the error happens again.

What it looks like is happening is the browser is being launched before the following is actually ready:

app.use(session({
    resave: true,
    saveUninitialized: true,
    secret: secrets.sessionSecret,
    store: new MongoStore({
        url: secrets.db,
        'auto_reconnect': true
    })
}));

MongoStore has a callback and If I move the following code into it, the problem is fixed:

/**
 * Start Express server.
 */
app.listen(app.get('port'), function () {
    console.log(
        'FreeCodeCamp server listening on port %d in %s mode',
        app.get('port'),
        app.get('env')
    );
});
@BerkeleyTrue BerkeleyTrue changed the title App "listens" before 'MongoStore' is ready Unknown Windows/connect-mongo bug Mar 18, 2015
@BerkeleyTrue BerkeleyTrue added the type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc. label Mar 18, 2015
@BerkeleyTrue
Copy link
Contributor

I have updated the title to better describe the issue. We have a good assumption that the issue stems from windows systems. It might be an issue with connect-mongo and windows or windows and mongodb driver. More investigation will need to be conducted to better understand the problem.

@ghost
Copy link
Author

ghost commented Mar 18, 2015

What version of connect-mongo do you guys have?

npm install is giving me: 0.4.2 but the latest is 0.7.0 according to https://www.npmjs.com/package/connect-mongo

Updating to the latest version using npm install connect-mongo@0.7.0 fixes the problem. I couldn't get it to error trying the exact same things I did before.

@BerkeleyTrue
Copy link
Contributor

0.7.0

@ghost
Copy link
Author

ghost commented Mar 18, 2015

npm install is giving me "0.4.2". The package.json says "^0.4.1". How did you get 0.7.0?

But that's the fix. To update to 0.7.0.

@ghost ghost mentioned this issue Mar 18, 2015
@BerkeleyTrue
Copy link
Contributor

I updated. Haven't committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.
Projects
None yet
Development

No branches or pull requests

1 participant