WizardFactory / BlogSyncer

one write posting all of the world
Apache License 2.0
3 stars 10 forks source link

connect.session()의 leak memory 문제. #341

Open kimalec opened 8 years ago

kimalec commented 8 years ago

NODE_ENV=production 으로 설정하고 실행하면 아래와 같은 에러 메세지가 나온다.

Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
kimalec commented 8 years ago

connect-mongo 라는 것으로 해결가능하다고 하나, 검토해보니 에러가 발생하고, 추가 수정이 필요해 보임.

mongoose.connect(connectInfo);

app.use(session({
    secret: 'WizardFactory',
    store: new (require('connect-mongo')(session))({ mongooseConnection: mongoose.connection })
}));

아래와 같은 에러가 발생함.

TypeError: Cannot read property 'connect.sid' of undefined
    at Layer.session [as handle] (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express-session/index.js:122:32)
    at trim_prefix (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:240:15)
    at /Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:208:9
    at Function.proto.process_params (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:269:12)
    at next (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:199:19)
    at Layer.expressInit [as handle] (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/middleware/init.js:23:5)
    at trim_prefix (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:240:15)
    at /Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:208:9
    at Function.proto.process_params (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:269:12)
    at next (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:199:19)
warn: { statusCode: 500,
  body: '"TypeError: Cannot read property 'connect.sid' of undefined\\n    at Layer.session [as handle] (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express-session/index.js:122:32)\\n    at trim_prefix (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:240:15)\\n    at /Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:208:9\\n    at Function.proto.process_params (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:269:12)\\n    at next (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:199:19)\\n    at Layer.expressInit [as handle] (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/middleware/init.js:23:5)\\n    at trim_prefix (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:240:15)\\n    at /Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:208:9\\n    at Function.proto.process_params (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:269:12)\\n    at next (/Users/aleckim/WebstormProjects/BlogSyncer/node_modules/express/lib/router/index.js:199:19)"',
  url: 'http://www.justwapps.com/kakao/bot_posts/updateToken?userid=558f7b04900a41fc8b815800' } cName=BlogBot, fName=_updateAccessToken, userId=558f7b04900a41fc8b815800