summaryrefslogtreecommitdiff
path: root/ext/websocket/lib.rs
diff options
context:
space:
mode:
authorAapo Alasuutari <aapo.alasuutari@gmail.com>2022-10-15 12:08:09 +0300
committerGitHub <noreply@github.com>2022-10-15 11:08:09 +0200
commit9c7a5c0c616eb309b582d61b61b9ef1cc4526909 (patch)
tree93dc229e6dbca0270647882e6fcb84697562d8fd /ext/websocket/lib.rs
parent225d516466a37a3695e051ca29456e424cb99aa2 (diff)
fix(ext/websocket): panic on no next ws message from an already closed stream (#16004)
Diffstat (limited to 'ext/websocket/lib.rs')
-rw-r--r--ext/websocket/lib.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs
index e8ada74a2..a31431377 100644
--- a/ext/websocket/lib.rs
+++ b/ext/websocket/lib.rs
@@ -489,7 +489,9 @@ pub async fn op_ws_next_event(
Some(Ok(Message::Pong(_))) => NextEventResponse::Pong,
Some(Err(e)) => NextEventResponse::Error(e.to_string()),
None => {
- state.borrow_mut().resource_table.close(rid).unwrap();
+ // No message was received, presumably the socket closed while we waited.
+ // Try close the stream, ignoring any errors, and report closed status to JavaScript.
+ let _ = state.borrow_mut().resource_table.close(rid);
NextEventResponse::Closed
}
};