-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Server closes connection if wrong type returned by handler #4572
Comments
@Fogapod thanks for the report! It'd be cool if you could submit a failing test marked with xfail in a PR as per https://pganssle-talks.github.io/xfail-lightning. |
@webknjaz alright, I'll try to make a test for this issue. I found that returning |
I think it is, or should be. Exceptions must be raised. |
aiohttp/aiohttp/web_protocol.py Lines 577 to 579 in f80029b
after calling aiohttp/aiohttp/web_protocol.py Line 480 in f80029b
and catched here aiohttp/aiohttp/web_protocol.py Lines 523 to 526 in f80029b
For some reason these are only logged in asyncio debug mode. I'm not sure how this could be fixed. Returning status 500 for all Runtime errors? |
I think so |
v3.6 deprecates returning exceptions but it still works (see the red warning box): https://docs.aiohttp.org/en/stable/web_quickstart.html#exceptions master/v4.0 doesn't support this anymore and doesn't mention returning exceptions: https://docs.aiohttp.org/en/latest/web_exceptions.html |
I don't understand this condition: aiohttp/aiohttp/web_protocol.py Lines 524 to 526 in f80029b
What kind of exceptions can happen there and why they are silenced by default? If there are exceptions that should be silenced and cause server to close connection without response, what could a workaround be? Raising different kind of exception from handler if wrong type returned? Edit: according to this comment #1790 (comment), runtime exceptions should not be handled, but in this case it can be, so exception type should be changed? |
🐞 Describe the bug
Server closes session if handler returns anything else that
Response
instance.💡 To Reproduce
~ curl localhost:8080 curl: (52) Empty reply from server
💡 Expected behavior
Error message in console and returned status 500.
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
Tested with aiohttp
3.6.2
andmaster
branch fresh installations.The text was updated successfully, but these errors were encountered: