Log last message when websocket reaches peak limit (#93038)
When we hit the absolute limit, we would log the last messages as it was key to finding out the source. We now do the same when we hit the peak limitpull/90445/head
parent
e073f091b1
commit
2848f8648d
|
@ -172,7 +172,7 @@ class WebSocketHandler:
|
|||
(
|
||||
"%s: Client unable to keep up with pending messages. Reached %s pending"
|
||||
" messages. The system's load is too high or an integration is"
|
||||
" misbehaving. Last message was: %s"
|
||||
" misbehaving; Last message was: %s"
|
||||
),
|
||||
self.description,
|
||||
MAX_PENDING_MSG,
|
||||
|
@ -209,11 +209,12 @@ class WebSocketHandler:
|
|||
(
|
||||
"%s: Client unable to keep up with pending messages. Stayed over %s for %s"
|
||||
" seconds. The system's load is too high or an integration is"
|
||||
" misbehaving"
|
||||
" misbehaving; Last message was: %s"
|
||||
),
|
||||
self.description,
|
||||
PENDING_MSG_PEAK,
|
||||
PENDING_MSG_PEAK_TIME,
|
||||
self._message_queue[-1],
|
||||
)
|
||||
self._cancel()
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ async def test_pending_msg_peak(
|
|||
|
||||
# Fill the queue past the allowed peak
|
||||
for _ in range(10):
|
||||
instance._send_message({})
|
||||
instance._send_message({"overload": "message"})
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, utcnow() + timedelta(seconds=const.PENDING_MSG_PEAK_TIME + 1)
|
||||
|
@ -79,7 +79,8 @@ async def test_pending_msg_peak(
|
|||
msg = await websocket_client.receive()
|
||||
assert msg.type == WSMsgType.close
|
||||
assert "Client unable to keep up with pending messages" in caplog.text
|
||||
assert "Stayed over 5 for 5 seconds"
|
||||
assert "Stayed over 5 for 5 seconds" in caplog.text
|
||||
assert "overload" in caplog.text
|
||||
|
||||
|
||||
async def test_pending_msg_peak_recovery(
|
||||
|
|
Loading…
Reference in New Issue