Skip to content

Commit dd3de36

Browse files
committed
Just re-raise the original exception, as-is
In Python `raise … from None` is an explicit request to raise the exception but to suppress any exception chaining. (See: https://docs.python.org/3/tutorial/errors.html#exception-chaining) This means that if, when an ASGI exception crashes, an exception causes another exception, that when the second exception (which has the first chained to it) reaches this point in the stack, these lines will re-raise it, but remove the chained exception. This can be confusing: ASGI frameworks will normally log a stack trace of the crashing application, but that stack trace will now be truncated, due to this `from None` removing the chained exception. The chained exception (which is the exception that kicked off the entire stack unwind) is usually the more interesting one, when you're debugging. Neither of the two changed lines seem to have a reason for `… from None`. Additionally, since they just re-raise the original exception, simply "`raise`" suffices. Fixes: #5624
1 parent adcd90c commit dd3de36

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sentry_sdk/integrations/asgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def _run_app(
183183

184184
except Exception as exc:
185185
self._capture_lifespan_exception(exc)
186-
raise exc from None
186+
raise
187187

188188
_asgi_middleware_applied.set(True)
189189
try:
@@ -259,7 +259,7 @@ async def _sentry_wrapped_send(
259259
)
260260
except Exception as exc:
261261
self._capture_request_exception(exc)
262-
raise exc from None
262+
raise
263263
finally:
264264
_asgi_middleware_applied.set(False)
265265

0 commit comments

Comments
 (0)