1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix(ext/websocket): Reland make try_send ops infallible (#16968)

Reverts denoland/deno#16743

This fixes the server hangs we were seeing in benchy. cc @billywhizz
This commit is contained in:
Divy Srivastava 2022-12-07 04:34:02 -08:00 committed by GitHub
parent 5dbc07935d
commit 791e623c32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -504,9 +504,12 @@ pub fn op_ws_try_send_string(
state: &mut OpState,
rid: ResourceId,
text: String,
) -> Result<bool, AnyError> {
let resource = state.resource_table.get::<WsStreamResource>(rid)?;
resource.try_send(Message::Text(text))
) -> bool {
let resource = match state.resource_table.get::<WsStreamResource>(rid) {
Ok(resource) => resource,
Err(_) => return false,
};
resource.try_send(Message::Text(text)).is_ok()
}
#[op(fast)]
@ -514,9 +517,12 @@ pub fn op_ws_try_send_binary(
state: &mut OpState,
rid: u32,
value: &[u8],
) -> Result<bool, AnyError> {
let resource = state.resource_table.get::<WsStreamResource>(rid)?;
resource.try_send(Message::Binary(value.to_vec()))
) -> bool {
let resource = match state.resource_table.get::<WsStreamResource>(rid) {
Ok(resource) => resource,
Err(_) => return false,
};
resource.try_send(Message::Binary(value.to_vec())).is_ok()
}
#[op(deferred)]