mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00: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:
parent
5dbc07935d
commit
791e623c32
1 changed files with 12 additions and 6 deletions
|
@ -504,9 +504,12 @@ pub fn op_ws_try_send_string(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
text: String,
|
text: String,
|
||||||
) -> Result<bool, AnyError> {
|
) -> bool {
|
||||||
let resource = state.resource_table.get::<WsStreamResource>(rid)?;
|
let resource = match state.resource_table.get::<WsStreamResource>(rid) {
|
||||||
resource.try_send(Message::Text(text))
|
Ok(resource) => resource,
|
||||||
|
Err(_) => return false,
|
||||||
|
};
|
||||||
|
resource.try_send(Message::Text(text)).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op(fast)]
|
#[op(fast)]
|
||||||
|
@ -514,9 +517,12 @@ pub fn op_ws_try_send_binary(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: u32,
|
rid: u32,
|
||||||
value: &[u8],
|
value: &[u8],
|
||||||
) -> Result<bool, AnyError> {
|
) -> bool {
|
||||||
let resource = state.resource_table.get::<WsStreamResource>(rid)?;
|
let resource = match state.resource_table.get::<WsStreamResource>(rid) {
|
||||||
resource.try_send(Message::Binary(value.to_vec()))
|
Ok(resource) => resource,
|
||||||
|
Err(_) => return false,
|
||||||
|
};
|
||||||
|
resource.try_send(Message::Binary(value.to_vec())).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op(deferred)]
|
#[op(deferred)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue