From dd3de3679c83847082ddfbf4ae200202a5ee1d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roy=20Wellington=20=E2=85=A3?= Date: Tue, 10 Mar 2026 16:35:41 -0400 Subject: [PATCH] Just re-raise the original exception, as-is MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sentry_sdk/integrations/asgi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/asgi.py b/sentry_sdk/integrations/asgi.py index 6983af89ed..bd17a973c0 100644 --- a/sentry_sdk/integrations/asgi.py +++ b/sentry_sdk/integrations/asgi.py @@ -183,7 +183,7 @@ async def _run_app( except Exception as exc: self._capture_lifespan_exception(exc) - raise exc from None + raise _asgi_middleware_applied.set(True) try: @@ -259,7 +259,7 @@ async def _sentry_wrapped_send( ) except Exception as exc: self._capture_request_exception(exc) - raise exc from None + raise finally: _asgi_middleware_applied.set(False)