diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-04-28 16:48:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 16:48:00 +0200 |
commit | 142c1ab9fcb6d88f36a8f9f096a59393525da7d0 (patch) | |
tree | e5bb04ca271146fcf91a68c87cb8c03bf19c5ac5 | |
parent | 0b296c6378c46c18de7c3838b2a3e1d13eb9bd87 (diff) |
fix(ext/websocket): restore op_ws_send_ping (#18891)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
-rw-r--r-- | cli/js/40_testing.js | 6 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 1 | ||||
-rw-r--r-- | cli/tests/testdata/run/websocket_server_idletimeout.ts | 4 | ||||
-rw-r--r-- | ext/websocket/lib.rs | 15 |
4 files changed, 20 insertions, 6 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 146448356..555f5f1fe 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -83,8 +83,8 @@ const OP_DETAILS = { "op_dns_resolve": ["resolve a DNS name", "awaiting the result of a `Deno.resolveDns` call"], "op_fdatasync_async": ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fdatasync` call"], "op_fetch_send": ["send a HTTP request", "awaiting the result of a `fetch` call"], - "op_ffi_call_nonblocking": ["do a non blocking ffi call", "awaiting the returned promise"] , - "op_ffi_call_ptr_nonblocking": ["do a non blocking ffi call", "awaiting the returned promise"], + "op_ffi_call_nonblocking": ["do a non blocking ffi call", "awaiting the returned promise"], + "op_ffi_call_ptr_nonblocking": ["do a non blocking ffi call", "awaiting the returned promise"], "op_flock_async": ["lock a file", "awaiting the result of a `Deno.flock` call"], "op_fs_events_poll": ["get the next file system event", "breaking out of a for await loop looping over `Deno.FsEvents`"], "op_fstat_async": ["get file metadata", "awaiting the result of a `Deno.File#fstat` call"], @@ -124,7 +124,7 @@ const OP_DETAILS = { "op_tls_start": ["start a TLS connection", "awaiting a `Deno.startTls` call"], "op_truncate_async": ["truncate a file", "awaiting the result of a `Deno.truncate` call"], "op_utime_async": ["change file timestamps", "awaiting the result of a `Deno.utime` call"], - "op_worker_recv_message": ["receive a message from a web worker", "terminating a `Worker`"], + "op_worker_recv_message": ["receive a message from a web worker", "terminating a `Worker`"], "op_ws_close": ["close a WebSocket", "awaiting until the `close` event is emitted on a `WebSocket`, or the `WebSocketStream#closed` promise resolves"], "op_ws_create": ["create a WebSocket", "awaiting until the `open` event is emitted on a `WebSocket`, or the result of a `WebSocketStream#connection` promise"], "op_ws_next_event": ["receive the next message on a WebSocket", "closing a `WebSocket` or `WebSocketStream`"], diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 1ad8efb26..26aacc6fd 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -4228,7 +4228,6 @@ async fn websocket_server_multi_field_connection_header() { // TODO(bartlomieju): this should use `deno run`, not `deno test`; but the // test hangs then. https://github.com/denoland/deno/issues/14283 #[tokio::test] -#[ignore] async fn websocket_server_idletimeout() { let script = util::testdata_path().join("run/websocket_server_idletimeout.ts"); diff --git a/cli/tests/testdata/run/websocket_server_idletimeout.ts b/cli/tests/testdata/run/websocket_server_idletimeout.ts index 9ae6698cb..211b5f6ea 100644 --- a/cli/tests/testdata/run/websocket_server_idletimeout.ts +++ b/cli/tests/testdata/run/websocket_server_idletimeout.ts @@ -1,5 +1,5 @@ -import { assertEquals } from "../../../test_util/std/testing/asserts.ts"; -import { deferred } from "../../../test_util/std/async/deferred.ts"; +import { assertEquals } from "../../../../test_util/std/testing/asserts.ts"; +import { deferred } from "../../../../test_util/std/async/deferred.ts"; const errorDeferred = deferred(); const closeDeferred = deferred(); diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 9ea341fbb..d2ec14ec3 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -406,6 +406,20 @@ pub async fn op_ws_send_pong( resource.write_frame(Frame::pong(vec![])).await } +#[op] +pub async fn op_ws_send_ping( + state: Rc<RefCell<OpState>>, + rid: ResourceId, +) -> Result<(), AnyError> { + let resource = state + .borrow_mut() + .resource_table + .get::<ServerWebSocket>(rid)?; + resource + .write_frame(Frame::new(true, OpCode::Ping, None, vec![])) + .await +} + #[op(deferred)] pub async fn op_ws_close( state: Rc<RefCell<OpState>>, @@ -499,6 +513,7 @@ deno_core::extension!(deno_websocket, op_ws_next_event, op_ws_send_binary, op_ws_send_text, + op_ws_send_ping, op_ws_send_pong, op_ws_server_create, ], |