New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #31962 -- Made SessionMiddleware raise SessionInterrupted when session destroyed while request is processing. #13395
Conversation
b8e6e0f
to
8ff6eb4
Compare
Here is the docs test error: Don't know how to fix it 😞 |
The error is because of a typo: "Intrupted". |
8ff6eb4
to
82b6613
Compare
Thanks @timgraham, and sorry for that 🤦♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hramezani Thanks for this patch 👍 I pushed edits to docs. This exception should trigger a 400 response (see comment), currently it's handled as a 500. We also a need test for this.
82b6613
to
4df64ea
Compare
Thanks @felixxm for the review and edit!
How can I handle this exception as a |
That's a good question. Maybe we can add a new core exception e.g. |
ca91fb3
to
f512100
Compare
django/core/handlers/exception.py
Outdated
@@ -76,6 +76,9 @@ def response_for_exception(request, exc): | |||
exc_info=sys.exc_info(), | |||
) | |||
|
|||
elif isinstance(exc, BadRequest): | |||
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixxm Do we need to use log_response
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should also return technical 500 page when DEBUG
is True. I fixed this.
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hramezani Thanks 👍
django/core/handlers/exception.py
Outdated
@@ -76,6 +76,9 @@ def response_for_exception(request, exc): | |||
exc_info=sys.exc_info(), | |||
) | |||
|
|||
elif isinstance(exc, BadRequest): | |||
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should also return technical 500 page when DEBUG
is True. I fixed this.
f512100
to
5d7c00f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
I had a slight worry about the status code… 400 the request is malformed… feels like the request is fine but it's unauthorized (the exact same request would succeed otherwise). HOWEVER I think 400 is probably the right way to go.
These kind of timing things are difficult. Makes you glad for ATOMIC_REQUESTS
.
Thanks @hramezani an @felixxm
…session destroyed while request is processing.
5d7c00f
to
4539674
Compare
Thanks Carlton! |
https://code.djangoproject.com/ticket/31962