Stop streaming logs when client closes connection (#5722)

When connection is closed by the client, the journal_logs_reader
generator still returns new lines, trying to write each one of them to
the closed transport. With debug logging enabled, this can end up in an
endless loop. To fix that, break out of the loop immediately after the
connection is reset.
This commit is contained in:
Jan Čermák 2025-03-04 10:08:44 +01:00 committed by GitHub
parent fdd96ae21c
commit 8fb66bcf18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -270,6 +270,7 @@ class APIHost(CoreSysAttributes):
"ClientConnectionResetError raised when returning journal logs: %s", "ClientConnectionResetError raised when returning journal logs: %s",
err, err,
) )
break
except ConnectionResetError as ex: except ConnectionResetError as ex:
raise APIError( raise APIError(
"Connection reset when trying to fetch data from systemd-journald." "Connection reset when trying to fetch data from systemd-journald."