#32049: Middleware behaviour inconsistent between runserver and daphne
------------------------------------------------+------------------------
               Reporter:  Hugo Osvaldo Barrera  |          Owner:  nobody
                   Type:  Bug                   |         Status:  new
              Component:  HTTP handling         |        Version:  3.1
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 All my views expect a particular middleware to have run (it detects the
 current tenant based on the request's host).

 I'm having an issue which ''only'' occurs on production, but I could not
 reproduce in development mode (even with `DEBUG=False`) nor via unit
 tests.

 After just inspecting stack traces, it seems that when `handler404` is
 run, behaviour varies between runserver and daphne.

 Looking at the backtrace of my `handler404` function:

 - When running `django-admin runserver 0.0.0.0:8000`, all my middlewares
 are in my backtrace, meaning they've gotten executed and the function is
 called in their context.
 - When running `daphne myapp.asgi:application --bind 0.0.0.0 --port 8000
 --http-timeout 90`, I put a tracepoint in my `handler404`, and the
 middleware **are not** in the backtrace. It seems that the view is run
 outside the context of these middlewares.

 I haven't been able to find anything in the docs clarifying whether error
 handlers should expect middleware to have run successfully, but whatever
 the ''intended'' behaviour is, it should be consistent across the two.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32049>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.cd7379a691f115a99c264dbc06f89e6f%40djangoproject.com.

Reply via email to