0

我正在使用 Node v4.4.0、npm 2.14.20 和sails 0.10.5。我已经使用 Google OAuth2 创建了简单的应用程序(我所拥有的只是具有用户模型的 Auth 控制器并在 config/passport.js 中配置了护照),它在本地运行时工作正常,但在 Heroku 上部署时失败。从日志中,我怀疑在用户已经通过 Google 身份验证后创建新会话存在问题。我在下面附加了一个日志,以前有人遇到过类似的问题吗?

016-03-16T18:54:01.206409+00:00 heroku[router]: at=info method=GET path="/login" host=porocila-treningov.herokuapp.com request_id=2650d7a4-0047-45b6-bd64-fbe122902c9b fwd="92.53.152.70" dyno=web.1 connect=5ms service=33ms status=200 bytes=1382
2016-03-16T18:54:33.179402+00:00 heroku[router]: at=info method=GET path="/auth/google" host=porocila-treningov.herokuapp.com request_id=e91d0c55-cf6a-4aef-b994-96c3b92bcf9a fwd="92.53.152.70" dyno=web.1 connect=0ms service=9ms status=302 bytes=528
2016-03-16T18:54:35.675271+00:00 app[web.1]: /app/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:72
2016-03-16T18:54:35.675281+00:00 app[web.1]:     self.sessions[sid] = JSON.stringify(sess);
2016-03-16T18:54:35.675282+00:00 app[web.1]:                               ^
2016-03-16T18:54:35.675283+00:00 app[web.1]: 
2016-03-16T18:54:35.675284+00:00 app[web.1]:     at Object.stringify (native)
2016-03-16T18:54:35.675284+00:00 app[web.1]: TypeError: Converting circular structure to JSON
2016-03-16T18:54:35.675286+00:00 app[web.1]:     at process._tickDomainCallback (node.js:390:13)
2016-03-16T18:54:35.675285+00:00 app[web.1]:     at /app/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:72:31
2016-03-16T18:54:35.675286+00:00 app[web.1]:     at nextTickCallbackWith0Args (node.js:420:9)
2016-03-16T18:54:35.696055+00:00 app[web.1]: 
2016-03-16T18:54:35.706858+00:00 app[web.1]: npm ERR! node v4.4.0
2016-03-16T18:54:35.707355+00:00 app[web.1]: npm ERR! npm  v2.14.20
------------SOME MORE CRASH INFO, HOW TO SUBMIT BUG, HOW TO FIND AUTHOR ETC-----------
2016-03-16T18:54:35.669056+00:00 heroku[router]: at=info method=GET path="/auth/google/callback?code=4/-OF3ImicWoSJkNfnoO60C7MNFVUtAj7YG2PXRUQkIUs" host=porocila-treningov.herokuapp.com request_id=a5578684-269c-44a0-abdc-2808517a4ea7 fwd="92.53.152.70" dyno=web.1 connect=0ms service=355ms status=302 bytes=409
2016-03-16T18:54:36.506369+00:00 heroku[web.1]: Process exited with status 1
2016-03-16T18:54:36.518470+00:00 heroku[web.1]: State changed from up to crashed
2016-03-16T18:54:37.792637+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=porocila-treningov.herokuapp.com request_id=1ab7a2b5-80fb-48b5-993d-ac0f213c996a fwd="92.53.152.70" dyno= connect= service= status=503 bytes=
4

1 回答 1

0

当您将某个对象分配给该对象的某个键时,会发生循环结构错误。例如...

var obj={
  'x':1,
  'y':false
};
obj.z=obj;//or anyhow this happens by mistake

看截图!!!

所以这是形成了圆形对象......并且在对这些对象进行字符串化时会导致异常。

于 2016-03-16T20:10:55.493 回答