avatarhzh
avatarhzh

Reputation: 2383

What's the meaning of this warning from Heroku logs

When I went to my app that's been pushed to Heroku, it took a long time to load. I waited for it to load but it got an error. The weird thing is yesterday going to the website was fine and I was able to load the site fine later on today as well. However when I got the error, I checked Heroku logs and got this warning:

2017-10-15T06:19:09.735366+00:00 app[web.1]: > node index.js
2017-10-15T06:19:09.735365+00:00 app[web.1]: > [email protected] start /app
2017-10-15T06:19:09.735367+00:00 app[web.1]: 
2017-10-15T06:19:10.515212+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-10-15T06:19:10.515232+00:00 app[web.1]: designed for a production environment, as it will leak
2017-10-15T06:19:10.515233+00:00 app[web.1]: memory, and will not scale past a single process.

I get that something in my code isn't designed for production but I'm not sure which part of my code this is referring to. I'm using passport.js for authorisation and have it wired with Google and Facebook strategies and I'm using express-session package in my index.js. Is this what the warning is pointing to? Can someone please explain what this warning could mean?

Upvotes: 0

Views: 84

Answers (1)

starleaf1
starleaf1

Reputation: 2872

You're using connect-session module, which handles HTTP sessions (obviously). This warning shows up because you don't configure the module to use any of the other ways of storing the session data (a database, a file, etc.). When you do this, connect-session uses memory as the session store.

This, however, isn't suited to production environment. It has memory leaks, which means your app would crash frequently.

More importantly, it won't work properly in a cloud environment (such as Heroku or Amazon Cloud or Google Cloud Platform) because in such environments your app runs in multiple instances. A session data stored in an app instance won't be accessible from another instance. This would result users repeatedly getting logged out, among other things.

Upvotes: 1

Related Questions