fix: Handle WSClient write failure when server closes WebSocket (#6671)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-04-07 20:15:40 +01:00
committed by GitHub
parent b0fe2ec58a
commit 6d1a5be8d2

View File

@@ -184,7 +184,14 @@ public:
jp[jss::command] = cmd;
}
auto const s = to_string(jp);
ws_.write_some(true, buffer(s));
// Use the error_code overload to avoid an unhandled exception
// when the server closes the WebSocket connection (e.g. after
// booting a client that exceeded resource thresholds).
error_code ec;
ws_.write_some(true, buffer(s), ec);
if (ec)
return {};
}
auto jv =