fix(ext/websocket): drop connection when close frame not ack (#24301)

Fixes #24292
This commit is contained in:
Divy Srivastava 2024-06-25 06:39:02 -07:00 committed by GitHub
parent 13aa1d70e9
commit a1ff1a453c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 2 deletions

View file

@ -699,10 +699,14 @@ pub async fn op_ws_close(
#[smi] code: Option<u16>,
#[string] reason: Option<String>,
) -> Result<(), AnyError> {
let resource = state
let Ok(resource) = state
.borrow_mut()
.resource_table
.get::<ServerWebSocket>(rid)?;
.get::<ServerWebSocket>(rid)
else {
return Ok(());
};
let frame = reason
.map(|reason| Frame::close(code.unwrap_or(1005), reason.as_bytes()))
.unwrap_or_else(|| Frame::close_raw(vec![].into()));