From ed95913c85fe7c62cf8ee17c43285800a3a6f4a8 Mon Sep 17 00:00:00 2001 From: Vadim Markovtsev Date: Tue, 2 Sep 2025 16:49:25 +0200 Subject: [PATCH] Avoid reporting false-positive StopAsyncIteration in the asyncio integration If a coroutine exits an async loop by raising AsyncStopIteration, Sentry reports it as an error. There is no error in that case. --- sentry_sdk/integrations/asyncio.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sentry_sdk/integrations/asyncio.py b/sentry_sdk/integrations/asyncio.py index ae580ca038..66742fe6e4 100644 --- a/sentry_sdk/integrations/asyncio.py +++ b/sentry_sdk/integrations/asyncio.py @@ -51,6 +51,8 @@ async def _task_with_sentry_span_creation(): ): try: result = await coro + except StopAsyncIteration as e: + raise e from None except Exception: reraise(*_capture_exception())