mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(ext/websocket): don't panic on bad resource id (#21431)
https://github.com/denoland/deno/issues/21379
This commit is contained in:
parent
5e24e28318
commit
0bee37a5e2
1 changed files with 6 additions and 6 deletions
|
@ -719,9 +719,9 @@ pub async fn op_ws_close(
|
|||
pub fn op_ws_get_buffer(
|
||||
state: &mut OpState,
|
||||
#[smi] rid: ResourceId,
|
||||
) -> ToJsBuffer {
|
||||
let resource = state.resource_table.get::<ServerWebSocket>(rid).unwrap();
|
||||
resource.buffer.take().unwrap().into()
|
||||
) -> Result<ToJsBuffer, AnyError> {
|
||||
let resource = state.resource_table.get::<ServerWebSocket>(rid)?;
|
||||
Ok(resource.buffer.take().unwrap().into())
|
||||
}
|
||||
|
||||
#[op2]
|
||||
|
@ -729,9 +729,9 @@ pub fn op_ws_get_buffer(
|
|||
pub fn op_ws_get_buffer_as_string(
|
||||
state: &mut OpState,
|
||||
#[smi] rid: ResourceId,
|
||||
) -> String {
|
||||
let resource = state.resource_table.get::<ServerWebSocket>(rid).unwrap();
|
||||
resource.string.take().unwrap()
|
||||
) -> Result<String, AnyError> {
|
||||
let resource = state.resource_table.get::<ServerWebSocket>(rid)?;
|
||||
Ok(resource.string.take().unwrap())
|
||||
}
|
||||
|
||||
#[op2]
|
||||
|
|
Loading…
Add table
Reference in a new issue