From 6d1a5be8d28e19feba530fed812ff28c341a1dc4 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Tue, 7 Apr 2026 20:15:40 +0100 Subject: [PATCH] fix: Handle WSClient write failure when server closes WebSocket (#6671) Co-authored-by: Claude Opus 4.6 --- src/test/jtx/impl/WSClient.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/jtx/impl/WSClient.cpp b/src/test/jtx/impl/WSClient.cpp index 0c9b72c4d0..2c3389c131 100644 --- a/src/test/jtx/impl/WSClient.cpp +++ b/src/test/jtx/impl/WSClient.cpp @@ -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 =