Handle ClientPayloadError in advanced logging (#5869)

When the systemd-journal-gatewayd service is being shutdown while
Supervisor is still trying to read logs, aiohttp throws a
ClientPayloadError, presumably because we try to read until the next
linefeed, which aiohttp cannot satisfy anymore.

Simply catch the exception just like the connection reset errors
previously in #5358 and #5715.
This commit is contained in:
Stefan Agner 2025-05-06 20:33:05 +02:00 committed by GitHub
parent 85f8107b60
commit 36da382af3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ from contextlib import suppress
import logging
from typing import Any
from aiohttp import ClientConnectionResetError, web
from aiohttp import ClientConnectionResetError, ClientPayloadError, web
from aiohttp.hdrs import ACCEPT, RANGE
import voluptuous as vol
from voluptuous.error import CoerceInvalid
@ -269,7 +269,8 @@ class APIHost(CoreSysAttributes):
err,
)
break
except ConnectionResetError as ex:
except (ConnectionResetError, ClientPayloadError) as ex:
# ClientPayloadError is most likely caused by the closing the connection
raise APIError(
"Connection reset when trying to fetch data from systemd-journald."
) from ex