summaryrefslogtreecommitdiff
path: root/ext/websocket/lib.rs
AgeCommit message (Collapse)Author
2024-11-04refactor(runtime/permissions): use concrete error types (#26464)Leo Kettmeir
2024-10-18refactor(ext/websocket): use concrete error type (#26226)Leo Kettmeir
2024-10-12refactor(ext/tls): use concrete error types (#26174)Leo Kettmeir
2024-07-02chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24388)Bartek Iwańczuk
Reland of https://github.com/denoland/deno/pull/24056 that doesn't suffer from the problem that was discovered in https://github.com/denoland/deno/pull/24261. It uses upgraded `hyper` and `hyper-util` that fixed the previous problem in https://github.com/hyperium/hyper/pull/3691.
2024-06-25fix(ext/websocket): drop connection when close frame not ack (#24301)Divy Srivastava
Fixes #24292
2024-06-19Revert "chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24056)" (#24262)Bartek Iwańczuk
This reverts commit fb31eaa9ca59f6daaee0210d5cd206185c7041b9. Reverting because users reported spurious errors when downloading dependencies - https://github.com/denoland/deno/issues/24260. Closes https://github.com/denoland/deno/issues/24260
2024-06-13chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24056)Bartek Iwańczuk
This commit updates Deno to use `reqwest` at 0.12.4 and `rustls` at 0.22. Other related crates were updated as well to match versions accepted by `reqwest` and `rustls`. Note: we are not using the latest available `rustls` yet, but this upgrade was non-trivial already, so a bump to 0.23 for `rustls` will be done in a separate commit. Closes #23370 --------- Signed-off-by: Ryan Dahl <ry@tinyclouds.org> Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-06-06refactor: remove `PermissionsContainer` in deno_runtime (#24119)David Sherret
Also removes permissions being passed in for node resolution. It was completely useless because we only checked it for reading package.json files, but Deno reading package.json files for resolution is perfectly fine. My guess is this is also a perf improvement because Deno is doing less work.
2024-05-09refactor(ext/tls): Implement required functionality for later SNI support ↵Matt Mastracci
(#23686) Precursor to #23236 This implements the SNI features, but uses private symbols to avoid exposing the functionality at this time. Note that to properly test this feature, we need to add a way for `connectTls` to specify a hostname. This is something that should be pushed into that API at a later time as well. ```ts Deno.test( { permissions: { net: true, read: true } }, async function listenResolver() { let sniRequests = []; const listener = Deno.listenTls({ hostname: "localhost", port: 0, [resolverSymbol]: (sni: string) => { sniRequests.push(sni); return { cert, key, }; }, }); { const conn = await Deno.connectTls({ hostname: "localhost", [serverNameSymbol]: "server-1", port: listener.addr.port, }); const [_handshake, serverConn] = await Promise.all([ conn.handshake(), listener.accept(), ]); conn.close(); serverConn.close(); } { const conn = await Deno.connectTls({ hostname: "localhost", [serverNameSymbol]: "server-2", port: listener.addr.port, }); const [_handshake, serverConn] = await Promise.all([ conn.handshake(), listener.accept(), ]); conn.close(); serverConn.close(); } assertEquals(sniRequests, ["server-1", "server-2"]); listener.close(); }, ); ``` --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-03-09fix(ext/websocket): do not continue reading if socket rid closes (#21849)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/21379
2024-02-06chore(ws): remove unused op_ws_send_pong (#22283)Divy Srivastava
2024-01-26refactor: migrate extensions to virtual ops module (#22135)Bartek Iwańczuk
First pass of migrating away from `Deno.core.ensureFastOps()`. A few "tricky" ones have been left for a follow up.
2024-01-25Revert "chore: bump rustls-tokio-stream and rustls (#21955)" (#22097)Bartek Iwańczuk
This reverts commit 971eb0e5e836cdeaaefc25b2bab4c6a6a9f8e213. To unblock v1.40 release.
2024-01-16chore: bump rustls-tokio-stream and rustls (#21955)Matt Mastracci
2024-01-09chore: upgrade deno_core to 0.244.0 (#21859)Bartek Iwańczuk
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-27refactor: simplify hyper, http, h2 deps (#21715)Bartek Iwańczuk
Main change is that: - "hyper" has been renamed to "hyper_v014" to signal that it's legacy - "hyper1" has been renamed to "hyper" and should be the default
2023-12-27refactor: finish test_util server cleanup, simplify dependencies (#21714)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/21578
2023-12-26refactor: fastwebsockets renames (#21707)Bartek Iwańczuk
We now use only a single version of "fastwebsockets" crate, so we no longer need to have an alias.
2023-12-26refactor: migrate ext/websocket to hyper 1.1 (#21699)Bartek Iwańczuk
2023-12-24chore: ensure that each op provided to ensureFastOps is only used once (#21689)Matt Mastracci
When we migrate to op-import-per-extension, we will want to ensure that ops have one and only one place where they are imported. This tackles the ops that are imported via `ensureFastOps`, but does not yet tackle direct `ops` imports. Landing ahead of https://github.com/denoland/deno_core/pull/393
2023-12-11fix(ext/websocket): don't panic on bad resource id (#21431)Divy Srivastava
https://github.com/denoland/deno/issues/21379
2023-11-01feat(ext/websocket): websockets over http2 (#21040)Matt Mastracci
Implements `WebSocket` over http/2. This requires a conformant http/2 server supporting the extended connect protocol. Passes approximately 100 new WPT tests (mostly `?wpt_flags=h2` versions of existing websockets APIs). This is implemented as a fallback when http/1.1 fails, so a server that supports both h1 and h2 WebSockets will still end up on the http/1.1 upgrade path. The patch also cleas up the websockets handshake to split it up into http, https+http1 and https+http2, making it a little less intertwined. This uncovered a likely bug in the WPT test server: https://github.com/web-platform-tests/wpt/issues/42896
2023-10-31feat(ext/websocket): use rustls-tokio-stream instead of tokio-rustls (#20518)Matt Mastracci
Use new https://github.com/denoland/rustls-tokio-stream project instead of tokio-rustls for direct websocket connections. This library was written from the ground up to be more reliable and should help with various bugs that may occur due to underlying bugs in the old library. Believed to fix #20355, #18977, #20948
2023-10-30feat(ext/websocket): split websocket read/write halves (#20579)Matt Mastracci
Fixes some UB when sending and receiving at the same time.
2023-10-25chore: update deno_core and port all remaining ops to `op2` (#20954)Bartek Iwańczuk
Signed-off-by: Matt Mastracci <matthew@mastracci.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-04refactor: rewrite websocket to use op2 macro (#20140)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-09-13chore: bump deno_core and cargo update (#20480)Matt Mastracci
Bump deno_core, pulling in new rusty_v8. Requires some op2/deprecation fixes.
2023-09-04Revert "refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' ↵Bartek Iwańczuk
(#20303) (#20370) This reverts commit https://github.com/denoland/deno/commit/83426be6eead06c680ae527468aeaf8723543ff2. Includes a regression test.
2023-09-02refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' (#20303)Bartek Iwańczuk
Rewrites 3 ops that used "op(deferred)" to use "op2(async(lazy))" instead. This will allow us to remove codepath for handling "deferred" ops in "deno_core".
2023-08-26chore: update to Rust 1.72 (#20258)林炳权
<!-- Before submitting a PR, please read https://deno.com/manual/contributing 1. Give the PR a descriptive title. Examples of good title: - fix(std/http): Fix race condition in server - docs(console): Update docstrings - feat(doc): Handle nested reexports Examples of bad title: - fix #7123 - update docs - fix bugs 2. Ensure there is a related issue and it is referenced in the PR text. 3. Ensure there are tests that cover the changes. 4. Ensure `cargo test` passes. 5. Ensure `./tools/format.js` passes without changing files. 6. Ensure `./tools/lint.js` passes. 7. Open as a draft PR if your work is still in progress. The CI won't run all steps, but you can add '[ci]' to a commit message to force it to. 8. If you would like to run the benchmarks on the CI, add the 'ci-bench' label. --> As the title. --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-23fix(ext/web): add stream tests to detect v8slice split bug (#20253)Matt Mastracci
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-10chore: upgrade fastwebsockets to 0.4.4 (#19089)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19041
2023-07-07perf(ext/websocket): optimize server websocket js (#19719)Divy Srivastava
Split from https://github.com/denoland/deno/pull/19686 - timestamp set to 0 for server websocket events. - take fast call path with op_ws_send_binary.
2023-06-29fix(ext/websocket): Ensure that errors are available after async response ↵Matt Mastracci
returns (#19642) Fixes the WPT tests that test w/invalid codes. Also explicitly ignoring some h2 tests to hopefully prevent flakes. The previous changes to WebSocketStream introduced a bug where the close errors were not made available if the `pull` method was re-entrant.
2023-06-22refactor(serde_v8): split ZeroCopyBuf into JsBuffer and ToJsBuffer (#19566)Bartek Iwańczuk
`ZeroCopyBuf` was convenient to use, but sometimes it did hide details that some copies were necessary in certain cases. Also it made it way to easy for the caller to pass around and convert into different values. This commit splits `ZeroCopyBuf` into `JsBuffer` (an array buffer coming from V8) and `ToJsBuffer` (a Rust buffer that will be converted into a V8 array buffer). As a result some magical conversions were removed (they were never used) limiting the API surface and preparing for changes in #19534.
2023-06-13fix(ext/websockets): ensure we fully send frames before close (#19484)Matt Mastracci
Fixes #19483
2023-06-08fix(ext/websocket): Close socket on bad string data (#19424)Matt Mastracci
2023-06-08perf(ext/websocket): Reduce GC pressure & monomorpize op_ws_next_event (#19405)Matt Mastracci
Reduce the GC pressure from the websocket event method by splitting it into an event getter and a buffer getter. Before: 165.9k msg/sec After: 169.9k msg/sec
2023-06-08perf: use sendto syscalls (#19414)Bartek Iwańczuk
This switches syscall used in HTTP and WS server from "writev" to "sendto". "DENO_USE_WRITEV=1" can be used to enable using "writev" syscall. Doing this for easier testing of various setups.
2023-06-06perf(ext/websocket): Make send sync for non-stream websockets (#19376)Matt Mastracci
No need to go through the async machinery for `send(String | Buffer)` -- we can fire and forget, and then route any send errors into the async call we're already making (`op_ws_next_event`). Early benchmark on MacOS: Before: 155.8k msg/sec After: 166.2k msg/sec (+6.6%) Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-18fix(ext/websocket): order of ws writes (#19131)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19041
2023-05-16refactor(ext/http): simpler ws server in http_next (#19133)Luca Casonato
Merges `op_http_upgrade_next` and `op_ws_server_create`, significantly simplifying websocket construction in ext/http (next), and removing one JS -> Rust call. Also WS server now doesn't bypass `HttpPropertyExtractor`.
2023-05-14refactor(core): bake single-thread assumptions into spawn/spawn_blocking ↵Matt Mastracci
(#19056) Partially supersedes #19016. This migrates `spawn` and `spawn_blocking` to `deno_core`, and removes the requirement for `spawn` tasks to be `Send` given our single-threaded executor. While we don't need to technically do anything w/`spawn_blocking`, this allows us to have a single `JoinHandle` type that works for both cases, and allows us to more easily experiment with alternative `spawn_blocking` implementations that do not require tokio (ie: rayon). Async ops (+~35%): Before: ``` time 1310 ms rate 763358 time 1267 ms rate 789265 time 1259 ms rate 794281 time 1266 ms rate 789889 ``` After: ``` time 956 ms rate 1046025 time 954 ms rate 1048218 time 924 ms rate 1082251 time 920 ms rate 1086956 ``` HTTP serve (+~4.4%): Before: ``` Running 10s test @ http://localhost:4500 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 68.78us 19.77us 1.43ms 86.84% Req/Sec 68.78k 5.00k 73.84k 91.58% 1381833 requests in 10.10s, 167.36MB read Requests/sec: 136823.29 Transfer/sec: 16.57MB ``` After: ``` Running 10s test @ http://localhost:4500 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 63.12us 17.43us 1.11ms 85.13% Req/Sec 71.82k 3.71k 77.02k 79.21% 1443195 requests in 10.10s, 174.79MB read Requests/sec: 142921.99 Transfer/sec: 17.31MB ``` Suggested-By: alice@ryhl.io Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-01perf: lazily create RootCertStore (#18938)David Sherret
2023-04-28fix(ext/websocket): client connect URI (#18892)Divy Srivastava
2023-04-28fix(ext/websocket): restore op_ws_send_ping (#18891)Bartek Iwańczuk
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-27perf(ext/websocket): various performance improvements (#18862)Bartek Iwańczuk
- No need to wrap buffer in a `new DataView()` - Deferred ops are still eagerly polled, but resolved on the next tick of the event loop, we don't want them to be eagerly polled - Using "core.opAsync"/"core.opAsync2" incurs additional cost of looking up these functions on each call. Similarly with "ops.*" --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-26chore(ext/websocket): remove ping frame handling (#18847)Divy Srivastava
Automatically done in the fastwebsockets crate
2023-04-25refactor(ext/websocket): use specialized ops (#18819)Bartek Iwańczuk
Instead of relying on `op_ws_send` to send different kinds of messages, use specialized ops everywhere.