fix(ext/websocket): panic on no next ws message from an already closed stream (#16004)

This commit is contained in:
Aapo Alasuutari 2022-10-15 12:08:09 +03:00 committed by GitHub
parent 225d516466
commit 9c7a5c0c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
};