#33674: Timezones cause 500 errors to not email the site admin
---------------------------------+--------------------------------------
     Reporter:  iragm            |                    Owner:  (none)
         Type:  Bug              |                   Status:  new
    Component:  Error reporting  |                  Version:  4.0
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------
Description changed by iragm:

Old description:

> I believe I have found a bug - my site was working great prior to adding
> support for localization/timezones and if a user encountered a 500
> internal server error, I'd get an email about it and could fix it.  I
> added support for timezones, and **stopped getting the alert emails** --
> and the users are no longer sent to my 500 page.
>
> Here's some information:
> * debug=True causes things to work correctly (no email sent, debug info
> displayed to the user)
> * this does not happen in a development environment at all as far as I
> can tell
> * I am using Channels and Daphne to serve content behind an Nginx reverse
> proxy
> * When 500 errors happen, the user gets redirected to a very generic
> Daphne "exception inside application" page.  Before you blame this on
> Daphne, please keep reading...
> * The error log traceback points to `site-
> packages/django/templatetags/tz.py`
>
> If I change this class to look as follows:
> {{{
>     def render(self, context):
>         try:
>             with timezone.override(self.tz.resolve(context)):
>                 output = self.nodelist.render(context)
>             return output
>         except:
>             return self.nodelist.render(context)
> }}}
> the correct 500 error page is rendered and the email goes out to me
> telling me where the error occurred.  That suggests to me that something
> in timezone.override isn't working as it should be.
>
> I could just make a PR with this but I am not really sure what
> consequences this change has.
>
> I know there's a lack of info in this, and I apologize in advance.
> Because I only see this issue on my production server, I have to take my
> whole site down to try to test and troubleshoot it.

New description:

 I believe I have found a bug - my site was working great prior to adding
 support for localization/timezones and if a user encountered a 500
 internal server error, I'd get an email about it and could fix it.  I
 added support for timezones, and **stopped getting the alert emails** --
 and the users are no longer sent to my 500 page.

 Here's some information:
 * debug=True causes things to work correctly (no email sent, debug info
 displayed to the user)
 * this does not happen in a development environment at all as far as I can
 tell
 * I am using Channels and Daphne to serve content behind an Nginx reverse
 proxy
 * Edit: using python3 manage.py runserver with debug=False returns the
 correct 500 page.  This issue is only happening when running with Daphne.
 * When 500 errors happen, the user gets redirected to a very generic
 Daphne "exception inside application" page.  Before you blame this on
 Daphne, please keep reading...
 * The error log traceback points to `site-
 packages/django/templatetags/tz.py`

 If I change this class to look as follows:
 {{{
     def render(self, context):
         try:
             with timezone.override(self.tz.resolve(context)):
                 output = self.nodelist.render(context)
             return output
         except:
             return self.nodelist.render(context)
 }}}
 the correct 500 error page is rendered and the email goes out to me
 telling me where the error occurred.  That suggests to me that something
 in timezone.override isn't working as it should be.

 I could just make a PR with this but I am not really sure what
 consequences this change has.

 I know there's a lack of info in this, and I apologize in advance. Because
 I only see this issue on my production server, I have to take my whole
 site down to try to test and troubleshoot it.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33674#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070180871d949d-ef024d5a-c022-4fca-850c-847151df7dfb-000000%40eu-central-1.amazonses.com.

Reply via email to