From 24be3d3a8928229581a65af8fca94e2e3023e5a9 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 19 Nov 2024 16:20:28 +0100 Subject: [PATCH] . --- sentry_sdk/integrations/wsgi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sentry_sdk/integrations/wsgi.py b/sentry_sdk/integrations/wsgi.py index 780beeb69a..ef06e76f52 100644 --- a/sentry_sdk/integrations/wsgi.py +++ b/sentry_sdk/integrations/wsgi.py @@ -264,6 +264,10 @@ def __iter__(self): try: chunk = next(iterator) except StopIteration: + # Close the Sentry transaction (it could be that response.close() is never called by the framework) + # This is done here to make sure the Transaction stays + # open until all streaming responses are done. + finish_running_transaction(self._current_scope) break except BaseException: reraise(*_capture_exception())