Skip to content

Commit

Permalink
Prevent generating an error during ws close (#4127)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
BlackDex authored Dec 4, 2023
1 parent 4883650 commit 0fdda3b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/api/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit 0fdda3b

Please sign in to comment.