From a8d664e1fed9fa0817e29970728613c85046f8cb Mon Sep 17 00:00:00 2001 From: BlackDex Date: Mon, 4 Dec 2023 17:07:21 +0100 Subject: [PATCH] Prevent generating an error during ws close When a WebSocket connection was closing it was sending a message after it was closed already. This generated an error in the logs. While this error didn't harm any of the functionallity of Vaultwarden it isn't nice to see them of course. This PR Fixes this by catching the close message and breaks the loop at that point. This prevents the `_` catch-all from replying the close message back to the client, which was causing the error message. Fixes #4090 --- src/api/notifications.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/notifications.rs b/src/api/notifications.rs index 5bcc59b5..da2664cf 100644 --- a/src/api/notifications.rs +++ b/src/api/notifications.rs @@ -164,6 +164,11 @@ fn websockets_hub<'r>( continue; } } + + // Prevent sending anything back when a `Close` Message is received. + // Just break the loop + Message::Close(_) => break, + // Just echo anything else the client sends _ => yield message, } @@ -230,6 +235,11 @@ fn anonymous_websockets_hub<'r>( continue; } } + + // Prevent sending anything back when a `Close` Message is received. + // Just break the loop + Message::Close(_) => break, + // Just echo anything else the client sends _ => yield message, }