summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
AgeCommit message (Collapse)Author
2024-11-12fix(ext/websocket): initialize `error` attribute of WebSocket ErrorEvent ↵Divy Srivastava
(#26796) Fixes https://github.com/denoland/deno/issues/26216 Not required by the spec but Discord.js depends on it, see https://github.com/denoland/deno/issues/26216#issuecomment-2466060306
2024-09-17refactor(ext/websocket): align error messages (#25622)Ian Bull
Aligns the error messages in the ext/websocket folder to be in-line with the Deno style guide. https://github.com/denoland/deno/issues/25269
2024-09-06fix(runtime): use more null proto objects again (#25040)Kenta Moriuchi
proceed with #23921 This PR is a preparation for https://github.com/denoland/deno_lint/pull/1307 --------- Signed-off-by: Kenta Moriuchi <moriken@kimamass.com> Co-authored-by: Luca Casonato <hello@lcas.dev>
2024-06-25fix(ext/websocket): drop connection when close frame not ack (#24301)Divy Srivastava
Fixes #24292
2024-06-20perf(ext/websocket): avoid global interceptor overhead (#24284)Divy Srivastava
2024-06-08fix(ext/websocket): correctly order messages when sending blobs (#24133)Luca Casonato
Previously the asynchronous read of the blob would not block sends that are started later. We now do this, but in such a way as to not regress performance in the common case of not using `Blob`.
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-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-10refactor: use `core.ensureFastOps()` (#21888)Kenta Moriuchi
2024-01-09fix(ext/websocket): pass on uncaught errors in idleTimeout (#21846)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/21840 The problem was hard to reproduce as its a race condition. I've added a test that reproduces the problem 1/10 tries. We should move the idleTimeout handling to Rust (maybe even built into fastwebsocket).
2024-01-04fix: strict type check for cross realms (#21669)Kenta Moriuchi
Deno v1.39 introduces `vm.runInNewContext`. This may cause problems when using `Object.prototype.isPrototypeOf` to check built-in types. ```js import vm from "node:vm"; const err = new Error(); const crossErr = vm.runInNewContext(`new Error()`); console.assert( !(crossErr instanceof Error) ); console.assert( Object.getPrototypeOf(err) !== Object.getPrototypeOf(crossErr) ); ``` This PR changes to check using internal slots solves them. --- current: ``` > import vm from "node:vm"; undefined > vm.runInNewContext(`new Error("message")`) Error {} > vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`) Date {} ``` this PR: ``` > import vm from "node:vm"; undefined > vm.runInNewContext(`new Error("message")`) Error: message at <anonymous>:1:1 > vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`) 2018-12-10T02:26:59.002Z ``` --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-02fix(ext/http): use arraybuffer binaryType for server websocket (#21741)Divy Srivastava
Ref https://github.com/denoland/deno/issues/15340#issuecomment-1872353134
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
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-13fix(websockets): server socket field initialization (#21433)Divy Srivastava
2023-12-07refactor: pull 'core', 'internals', 'primordials' from ES module (#21462)Bartek Iwańczuk
This commit refactors how we access "core", "internals" and "primordials" objects coming from `deno_core`, in our internal JavaScript code. Instead of capturing them from "globalThis.__bootstrap" namespace, we import them from recently added "ext:core/mod.js" file.
2023-11-19fix(ext,runtime): add missing custom inspections (#21219)Kenta Moriuchi
2023-10-10fix(ext/web): writability of `ReadableStream.from` (#20836)Luca Casonato
Fixes a WPT in `URL` and `ReadableStream`. Some unrelated WPT expectation changes due to WPT update.
2023-10-04refactor: rewrite websocket to use op2 macro (#20140)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-09-07feat: support import attributes (#20342)David Sherret
2023-08-20perf(ext/event): always set timeStamp to 0 (#20191)Bartek Iwańczuk
```js Deno.bench(function eventNew() { new Event("foo"); }); ``` <b>main</b> ``` ./target/release/deno bench event_bench.js cpu: Apple M1 Max runtime: deno 1.36.1 (aarch64-apple-darwin) file:///Users/ib/dev/deno/event_bench.js benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- eventNew 36.43 ns/iter 27,451,874.9 (35.15 ns … 46.98 ns) 37.68 ns 40.7 ns 41.69 ns ``` <b>this PR</b> ``` ./target/release/deno bench event_bench.js cpu: Apple M1 Max runtime: deno 1.36.1 (aarch64-apple-darwin) file:///Users/ib/dev/deno/event_bench.js benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- eventNew 13.71 ns/iter 72,958,970.0 (12.85 ns … 31.79 ns) 15.11 ns 16.49 ns 17.5 ns ``` Towards #20167
2023-07-31fix: call setIsTrusted for generated events (MessageEvent) (#19919)Ricardo Iván Vieitez Parra
This addresses issue #19918. ## Issue description Event messages have the wrong isTrusted value when they are not triggered by user interaction, which differs from the browser. In particular, all MessageEvents created by Deno have isTrusted set to false, even though it should be true. This is my first ever contribution to Deno, so I might be missing something.
2023-07-28feat(ext/websocket): allow HTTP(S) protocol in URL (#19862)Leo Kettmeir
Closes #19093
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-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-07perf(ext/websocket): monomorphize code (#19394)Bartek Iwańczuk
Using `deopt-explorer` I found that a bunch of fields on `WebSocket` class were polymorphic. Fortunately it was enough to initialize them to `undefined` to fix the problem.
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-06-06refactor(core): ensureFastOps is an op-generating proxy (#19377)Matt Mastracci
Startup benchmark shows no changes (within 1ms, identical system/user times).
2023-06-05chore: update deno_lint to 0.46.0 (#19372)Kenta Moriuchi
2023-06-05perf: optimize RegExp usage in JS (#19364)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/19330 Shows about 1% improvement in the HTTP benchmark.
2023-05-01refactor: migrate async ops to generated wrappers (#18937)Bartek Iwańczuk
Migrates some of existing async ops to generated wrappers introduced in https://github.com/denoland/deno/pull/18887. As a result "core.opAsync2" was removed. I will follow up with more PRs that migrate all the async ops to generated wrappers.
2023-05-01refactor(webidl): move prefix & context out of converters options bag (#18931)Leo Kettmeir
2023-04-30perf(ext/websocket): use internal dispatch for msg events (#18904)Divy Srivastava
``` Linux divy-2 5.19.0-1022-gcp #24~22.04.1-Ubuntu SMP Sun Apr 23 09:51:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux 32GiB System memory Intel(R) Xeon(R) CPU @ 3.10GHz # main Msg/sec: 89398.250000 Msg/sec: 90079.750000 # this patch Msg/sec: 91919.750000 Msg/sec: 91762.250000 ```
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.
2023-04-20refactor(ext/websocket): use fastwebsockets client (#18725)Divy Srivastava
2023-04-14fix(core): Use safe primordials wrappers (#18687)Kenta Moriuchi
2023-04-12refactor(ext/webidl): remove object from 'requiredArguments' (#18674)Bartek Iwańczuk
This should produce a little less garbage and using an object here wasn't really required. --------- Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com> Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2023-04-06perf(ext/websocket): replace tokio_tungstenite server with fastwebsockets ↵Divy Srivastava
(#18587) https://github.com/littledivy/fastwebsockets ``` # This PR ./load_test 100 0.0.0.0 8080 0 0 Running benchmark now... Msg/sec: 176355.000000 # main ./load_test 100 0.0.0.0 8080 0 0 Running benchmark now... Msg/sec: 157198.750000 ```
2023-04-02chore: Turn back on dlintPreferPrimordials (#17715)Kenta Moriuchi
Closes #17709
2023-03-31perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525)Divy Srivastava
This commit adds a new core API `opAsync2` to call an async op with atmost 2 arguments. Spread argument iterators has a pretty big perf hit when calling ops. | name | avg msg/sec/core | | --- | --- | | 1.32.1 | `127820.750000` | | #18506 | `140079.000000` | | #18506 + #18509 | `150104.250000` | | #18506 + #18509 + this | `157340.000000` |
2023-03-31perf(ext/websocket): efficient event kind serialization (#18509)Divy Srivastava
Use u16 to represent the kind of event (0 - 6) & event code > 6 is treated as the close code. This way we can represent all events + the close code in a single JS number. This is safe because (as per RFC 6455) close code from 0-999 are reserved & not used. | name | avg msg/sec/core | | --- | --- | | deno_main | `127820.750000` | | deno #18506 | `140079.000000` | | deno #18506 + this | `150104.250000` |
2023-03-30perf(ext/websocket): special op for sending binary data frames (#18506)Divy Srivastava
Easy perf win by avoiding deserializing `SendValue` through serde_v8. | name | avg msg/sec/core | | --- | --- | | deno_main | `127820.750000` | | deno_this | `140079.000000` |
2023-03-30perf(ext/websocket): special op for sending text data frames (#18507)Divy Srivastava
Similar to #18506 but for Text frames.
2023-03-08refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme ↵Bartek Iwańczuk
for snapshotted modules (#18041) This commit renames "deno_core::InternalModuleLoader" to "ExtModuleLoader" and changes the specifiers used by the modules loaded from this loader to "ext:". "internal:" scheme was really ambiguous and it's more characters than "ext:", which should result in slightly smaller snapshot size. Closes https://github.com/denoland/deno/issues/18020
2023-02-13fix(ext/websocket): extra ws pongs sent (#17762)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/17761 Tugstenite already sends a pong for a recieved ping. This automatically happens when the socket read is being driven. From https://github.com/snapview/tokio-tungstenite/issues/88 > You need to read from the read-side of the socket so that it receives/handles pings, and on the next write it would then send the corresponding pong. Here's the source: https://github.com/snapview/tungstenite-rs/blob/e1033afd959bb7abfcbc181033b8326f8a40562b/src/protocol/mod.rs#L374-L380 ```rust // Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in // response, unless it already received a Close frame. It SHOULD // respond with Pong frame as soon as is practical. (RFC 6455) if let Some(pong) = self.pong.take() { trace!("Sending pong reply"); self.send_one_frame(stream, pong)?; } ``` WIth this patch, all Autobahn tests from 1-8 pass. Fixed cases: 2.1, 2.2, 2.3, 2.4, 2.6, 2.9, 2.10, 2.11, 5.6, 5.7, 5.8, 5.19, 5.20 To run the test yourself, follow https://www.notion.so/denolandinc/Autobahn-WebSocket-testsuite-723a86f450ce4823b4ef9cb3dc4c7869?pvs=4
2023-02-07 refactor: remove prefix from include_js_files & use extension name (#17683)Leo Kettmeir
2023-02-07refactor: Use ES modules for internal runtime code (#17648)Leo Kettmeir
This PR refactors all internal js files (except core) to be written as ES modules. `__bootstrap`has been mostly replaced with static imports in form in `internal:[path to file from repo root]`. To specify if files are ESM, an `esm` method has been added to `Extension`, similar to the `js` method. A new ModuleLoader called `InternalModuleLoader` has been added to enable the loading of internal specifiers, which is used in all situations except when a snapshot is only loaded, and not a new one is created from it. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>