Skip to content

Commit ea606ca

Browse files
committed
Properly return lower-level error messages from the WebSocket
These are not yet surfaced anywhere useful in the UI, but at least they show up in the WebSocket inspector.
1 parent dd8a8cd commit ea606ca

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

ui/src/server_axum/websocket.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,20 +343,25 @@ async fn handle_core(mut socket: WebSocket, feature_flags: FeatureFlags) {
343343

344344
// We don't care if there are no running tasks
345345
Some(task) = manager.join_next() => {
346-
let Err(error) = task else { continue };
347-
// The task was cancelled; no need to report
348-
let Ok(panic) = error.try_into_panic() else { continue };
349-
350-
let text = match panic.downcast::<String>() {
351-
Ok(text) => *text,
352-
Err(panic) => match panic.downcast::<&str>() {
353-
Ok(text) => text.to_string(),
354-
_ => "An unknown panic occurred".into(),
346+
let error = match task {
347+
Ok(Ok(())) => continue,
348+
Ok(Err(error)) => error,
349+
Err(error) => {
350+
// The task was cancelled; no need to report
351+
let Ok(panic) = error.try_into_panic() else { continue };
352+
353+
let text = match panic.downcast::<String>() {
354+
Ok(text) => *text,
355+
Err(panic) => match panic.downcast::<&str>() {
356+
Ok(text) => text.to_string(),
357+
_ => "An unknown panic occurred".into(),
358+
}
359+
};
360+
WebSocketTaskPanicSnafu { text }.build()
355361
}
356362
};
357-
let error = WebSocketTaskPanicSnafu { text }.fail();
358363

359-
if tx.send(error).await.is_err() {
364+
if tx.send(Err(error)).await.is_err() {
360365
// We can't send a response
361366
break;
362367
}

0 commit comments

Comments
 (0)