Skip to content

Commit feafded

Browse files
authored
Merge pull request #39 from ryanfowler/fix-worker-thread-panic-resilience
Catch panics in worker thread to keep connection alive
2 parents 4eb2f25 + d62a24b commit feafded

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ impl Client {
153153

154154
while let Ok(cmd) = conn_rx.recv() {
155155
match cmd {
156-
Command::Func(func) => func(&mut conn),
156+
Command::Func(func) => {
157+
let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
158+
func(&mut conn);
159+
}));
160+
}
157161
Command::Shutdown(func) => match conn.close() {
158162
Ok(()) => {
159163
func(Ok(()));

0 commit comments

Comments
 (0)