Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
Adds a Python logging logger to the ASGI module so errors are surfaced to stderr instead of silently swallowed.
Issues
-
Bug —
logger.exception()in done callback loses traceback (asgi.py:24):logger.exception()relies onsys.exc_info()to capture the traceback, but future done callbacks execute outside anyexceptblock, sosys.exc_info()returns(None, None, None). The exception type and traceback are silently dropped. Uselogger.error(..., exc_info=exc)to pass the exception object directly — Python's logging will extract the traceback from it. -
Bug — two test assertions will fail (
worker.py:175-176,worker.py:203-204):r.getMessage()only returns the formatted message string (e.g."Unhandled exception in background task"), not the exception text. The tests check for the exception's message (e.g."post-response error for testing") insidegetMessage(), which will never match. The assertions need to inspectr.exc_infoor user.exc_text/ format the full record instead.
|
I'm Bonk, and I've done a quick review of your PR. Adds a Python Issues found
All three issues have concrete suggestion comments posted on the PR. |
e833768 to
045fa61
Compare
Adds logger to the Python ASGI module, users can overwrite the logger behavior by
before this change, all the errors were not showed to the user at all, while after this change, errors are caught and showed to stderr.
For example, the bug reported in https://discord.com/channels/595317990191398933/1224715939581530112/1473759889582194758 which showed nothing now shows
which helps us to debug the issue.