Exception.__context__ circular reference to containing ExceptionGroup #2942
Unanswered
Arnatious
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running into an issue using python 3.12, starlette 0.46.2 and rich 14 where exceptions raised in a route, when the asgi app has middleware, are causing rich to enter an infinite recursion when generating the traceback for logging.
Rich tries to follow the
__context__
of the exception, which points to the ExceptionGroup that contains it, causing an infinite loop.This #2893 bug seems to cover something similar, but it claims to be fixed. I have also reported it to rich at Textualize/rich#3682 but it seems hyper specific to starlette, and I don't think the context should be set this way but I'm having trouble following the exception in the debugger.
Here's a minimal example that produces this error
The logging of
Exception("original exception")
leads to an infinite loop as the__context__
ofException("original exception")
isExceptionGroup('unhandled errors in a TaskGroup', [Exception('original exception')])
.The middleware is important for some reason, it doesn't occur when there is no middleware. Note the fact that this middleware is essentially no-op. A middleware added with the
@app,middleware('http')
decorator also triggers it. Anyio is not required, it also occurs with pureasyncio
.Beta Was this translation helpful? Give feedback.
All reactions