Heroku one request spawns two responses that crashes my app

亡梦爱人 提交于 2019-12-25 18:36:32

问题


In my Heroku Django app, for the user account registration flow, there is a typical request activate account that happens when the user receives an email with a special "activate" URL. In the app, this activation should happen only once. The only identifier on that URL is an activation token. The token is used to "activate" the account, and also to identify the user (retrieve his username from the DB). Once this token is used, it is deleted.

For that reason, activation must happen only once. However, for really odd reasons, when the request is sent to my Heroku app, it triggers the activate function twice. I am quite sure this is not a programming mistake in the app, because on local development the activation is not called twice, and neither on staging environment (which is on Heroku too, almost identical to production settings). It only happens in production.

Here is what I see in heroku logs: http://pastebin.com/QeuP74fa

The first quarter of this log is interesting. Notice that at some point activation succeeded and attempted to redirect the user to the next correct page: GET Request to /iro/dashboard. But then after that the activation request happens, hence the crash that you see related to a "NoneType" object has no attribute...

My Procfile looks like this

web: newrelic-admin run-program gunicorn --bind=0.0.0.0:$PORT --workers=1 --log-level=debug iroquote.wsgi:application
worker: python manage.py rqworker high default low

I had 2 web dynos running, and 1 worker dyno, when I found the bug. I have tried to scale down to 1 web dyno and 1 worker, same bug. Then 0 dynos at all, and restarted 1 web dyno, still 0 worker, same bug.

Might something related to the Heroku router calling the dyno twice, or might not.

Help?


回答1:


Silently, it stopped happening. This was likely a routing problem in Heroku that affected my app.



来源:https://stackoverflow.com/questions/16972593/heroku-one-request-spawns-two-responses-that-crashes-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!