summaryrefslogtreecommitdiff
path: root/tests/unit_node
AgeCommit message (Collapse)Author
2024-08-07feat(ext/node): rewrite crypto keys (#24463)Luca Casonato
This completely rewrites how we handle key material in ext/node. Changes in this PR: - **Signing** - RSA - RSA-PSS 🆕 - DSA 🆕 - EC - ED25519 🆕 - **Verifying** - RSA - RSA-PSS 🆕 - DSA 🆕 - EC 🆕 - ED25519 🆕 - **Private key import** - Passphrase encrypted private keys 🆕 - RSA - PEM - DER (PKCS#1) 🆕 - DER (PKCS#8) 🆕 - RSA-PSS - PEM - DER (PKCS#1) 🆕 - DER (PKCS#8) 🆕 - DSA 🆕 - EC - PEM - DER (SEC1) 🆕 - DER (PKCS#8) 🆕 - X25519 🆕 - ED25519 🆕 - DH - **Public key import** - RSA - PEM - DER (PKCS#1) 🆕 - DER (PKCS#8) 🆕 - RSA-PSS 🆕 - DSA 🆕 - EC 🆕 - X25519 🆕 - ED25519 🆕 - DH 🆕 - **Private key export** - RSA 🆕 - DSA 🆕 - EC 🆕 - X25519 🆕 - ED25519 🆕 - DH 🆕 - **Public key export** - RSA - DSA 🆕 - EC 🆕 - X25519 🆕 - ED25519 🆕 - DH 🆕 - **Key pair generation** - Overhauled, but supported APIs unchanged This PR adds a lot of new individual functionality. But most importantly because of the new key material representation, it is now trivial to add new algorithms (as shown by this PR). Now, when adding a new algorithm, it is also widely supported - for example previously we supported ED25519 key pair generation, but we could not import, export, sign or verify with ED25519. We can now do all of those things.
2024-08-06feat: vm rewrite (#24596)snek
rewrite vm implementation to increase compat. vm.Module+importModuleDynamically callbacks should be added in a followup.
2024-08-06feat(fetch): accept async iterables for body (#24623)Leo Kettmeir
Implements https://github.com/whatwg/webidl/pull/1397 Fixes #21454 Closes #24849
2024-08-02Revert "feat: async context" (#24856)snek
Reverts denoland/deno#24402 deno_web can't depend on code in runtime
2024-08-02feat: async context (#24402)snek
We are switching to ContinuationPreservedEmbedderData. This allows adding async context tracking to the various async operations that deno provides. Fixes: https://github.com/denoland/deno/issues/7010 Fixes: https://github.com/denoland/deno/issues/22886 Fixes: https://github.com/denoland/deno/issues/24368
2024-08-02fix(ext/node): node:zlib coerces quality 10 to 9.5 (#24850)Bartek Iwańczuk
Fixes https://github.com/denoland/deno/issues/24572
2024-08-02Revert "perf(ext/node): improve `Buffer` from string performance" (#24851)Luca Casonato
2024-08-01fix(ext/crypto): respect offsets when writing into ab views in ↵Luca Casonato
randomFillSync (#24816)
2024-07-31fix(node/fs/promises): watch should be async iterable (#24805)Marvin Hagemeister
The way `fs.watch` works is different in `node:fs/promises` than `node:fs`. It has a different function signature and it returns an async iterable instead, see https://nodejs.org/api/fs.html#fspromiseswatchfilename-options Fixes https://github.com/denoland/deno/issues/24661
2024-07-31fix(node/timers/promises): add scheduler APIs (#24802)Marvin Hagemeister
This PR adds the experimental `scheduler` APIs in Node's `timers/promises` module. See https://nodejs.org/api/timers.html#timerspromisesschedulerwaitdelay-options Fixes https://github.com/denoland/deno/issues/24800
2024-07-30fix(node): Rework node:child_process IPC (#24763)Nathan Whitaker
Fixes https://github.com/denoland/deno/issues/24756. Fixes https://github.com/denoland/deno/issues/24796. This also gets vitest working when using [`--pool=forks`](https://vitest.dev/guide/improving-performance#pool) (which is the default as of vitest 2.0). Ref https://github.com/denoland/deno/issues/23882. --- This PR resolves a handful of issues with child_process IPC. In particular: - We didn't support sending typed array views over IPC - Opening an IPC channel resulted in the event loop never exiting - Sending a `null` over IPC would terminate the channel - There was some UB in the read implementation (transmuting an `&[u8]` to `&mut [u8]`) - The `send` method wasn't returning anything, so there was no way to signal backpressure (this also resulted in the benchmark `child_process_ipc.mjs` being misleading, as it tried to respect backpressure. That gave node much worse results at larger message sizes, and gave us much worse results at smaller message sizes). - We weren't setting up the `channel` property on the `process` global (or on the `ChildProcess` object), and also didn't have a way to ref/unref the channel - Calling `kill` multiple times (or disconnecting the channel, then calling kill) would throw an error - Node couldn't spawn a deno subprocess and communicate with it over IPC
2024-07-30perf(ext/node): improve `Buffer` from string performance (#24567)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/24323 - Use a Buffer pool for `fromString` - Implement fast call base64 writes - Direct from string `create` method for each encoding op ``` $ deno bench -A bench.mjs # 1.45.1+fee4d3a cpu: Apple M1 Pro runtime: deno 1.45.1+fee4d3a (aarch64-apple-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------- ----------------------------- Buffer.from base64 550 ns/iter (490 ns … 1'265 ns) 572 ns 606 ns 1'265 ns Buffer#write base64 285 ns/iter (259 ns … 371 ns) 307 ns 347 ns 360 ns $ ~/gh/deno/target/release/deno bench -A bench.mjs # this PR cpu: Apple M1 Pro runtime: deno dev (aarch64-apple-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------- ----------------------------- Buffer.from base64 151 ns/iter (145 ns … 770 ns) 148 ns 184 ns 648 ns Buffer#write base64 62.58 ns/iter (60.79 ns … 157 ns) 61.65 ns 75.79 ns 141 ns $ node bench.mjs # v22.4.0 cpu: Apple M1 Pro runtime: node v22.4.0 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------- ----------------------------- Buffer.from base64 163 ns/iter (96.92 ns … 375 ns) 99.45 ns 127 ns 220 ns Buffer#write base64 75.48 ns/iter (74.97 ns … 134 ns) 75.17 ns 81.83 ns 96.84 ns ```
2024-07-29fix(ext/node): prevent panic in http2.connect with uppercase header names ↵Satya Rohith
(#24780) Closes https://github.com/denoland/deno/issues/24678
2024-07-27test(ext/node): reduce http_test flakiness (#24742)Yoshiya Hinosawa
2024-07-25chore: update to `std@2024.07.19` (#24715)Asher Gomez
2024-07-24fix(ext/node/net): emit `error` before `close` when connection is refused ↵Yoshiya Hinosawa
(#24656)
2024-07-19fix(node): support `tty.hasColors()` and `tty.getColorDepth()` (#24619)Marvin Hagemeister
This PR adds support for [`tty.WriteStream.prototype.hasColors()`](https://nodejs.org/api/tty.html#writestreamhascolorscount-env) and [`tty.WriteStream.prototype.getColorDepth()`](https://nodejs.org/api/tty.html#writestreamgetcolordepthenv). I couldn't find any usage on GitHub which passes parameters to it. Therefore I've skipped adding support for the `env` parameter to keep our snapshot size small. Based on https://github.com/denoland/deno_terminal/pull/3 Fixes https://github.com/denoland/deno/issues/24616
2024-07-16fix(ext/node): http request uploads of subarray of buffer should work (#24603)Satya Rohith
Closes https://github.com/denoland/deno/issues/24571
2024-07-15fix(std/http2): release window capacity back to remote stream (#24576)Rano | Ranadeep
This PR adds logic to release window capacity after reading the chunks from the stream. Without it, large response (more than `u16::MAX`) may fill up the capacity and the whole response can't be read. Closes https://github.com/denoland/deno/issues/24552 Closes https://github.com/denoland/deno/issues/24305
2024-07-10fix(node/perf_hooks): stub eventLoopUtilization (#24501)Marvin Hagemeister
This PR stubs `perf_hooks.eventLoopUtilization` to make the tests of [hapi](https://github.com/hapijs/hapi) start. Previously, they'd all error because of this function throwing a not implemented error. This brings down the test failures in their suite from 982 to 68 failures.
2024-07-10fix(node/http): don't send destroyed requests (#24498)Marvin Hagemeister
Make sure that already destroyed requests are not actually sent. This error was discovered in jsdom's test suite.
2024-07-10fix(node/http): don't error if request destroyed before send (#24497)Marvin Hagemeister
A request can be destroyed before it was even made in the Node http API. We errored on that. This issue was discovered in the JSDOM test suite.
2024-07-09fix(node/http): support all `.writeHead()` signatures (#24469)Marvin Hagemeister
Implement the missing `.writeHead()` signatures from Node's `ServerResponse` class that we didn't support. Fixes https://github.com/denoland/deno/issues/24468
2024-07-08fix(node/assert): throws not checking error instance (#24466)Marvin Hagemeister
The implementation for `assert.throws()` from `node:assert` didn't work when the expected value was an `Error` constructor. In this case the thrown error should checked if it's an instance of said constructor. Fixes https://github.com/denoland/deno/issues/24464
2024-07-05fix(ext/node): rewrite digest handling (#24392)Luca Casonato
Previously we had many different code paths all handling digests in different places, all with wildly different digest support. This commit rewrites this to use a single digest handling mechanism for all digest operations. It adds various aliases for digest algorithms, like node does. For example `sha1WithRSAEncryption` is an alias for `sha1`. It also adds support for `md5-sha1` digests in various places.
2024-07-05fix(ext/node): http chunked writes hangs (#24428)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/24239
2024-07-04fix(node/http): don't throw on .address() before .listen() (#24432)Marvin Hagemeister
It's perfectly valid to access `server.address()` before calling `.listen()`. Until a server actively listens on a socket Node will return `null` here, but we threw a "Cannot access property 'port' of undefined" instead. This was discovered when inspecting failures in Koa's test suite with Deno.
2024-07-03fix(ext/node): don't wait for end() call to send http client request (#24390)Satya Rohith
Closes https://github.com/denoland/deno/issues/24232 Closes https://github.com/denoland/deno/issues/24215
2024-06-26perf(ext/node): improve `Buffer.from(buffer)` (#24352)ud2
Benchmark code from #24341. ```shellsession $ deno run --allow-hrtime bench.mjs 6479.111583 $ target/release/deno run --allow-hrtime bench.mjs 962.753875 $ node bench.mjs 855.174875 ```
2024-06-25fix(ext/node): ignore stream error during enqueue (#24243)Satya Rohith
2024-06-24fix(ext/node): rewrite crypto.Hash (#24302)Luca Casonato
Changes in this PR: - Added new fixed size hash algorithms (blake2b512, blake2s256, sha512-224, sha512-256, sha3-224, sha3-256, sha3-384, sha3-512, sm3) - Added variable size hash algorithms (the concept), with the algorithms shake128 and shake256 - Use cppgc instead of resources for the hasher - Enable Node's crypto.Hash tests and fix found bugs
2024-06-21fix(ext/node): add ServerResponse#appendHeader (#24216)Divy Srivastava
2024-06-21fix(ext/node): don't panic on invalid utf-8 in pem (#24303)Luca Casonato
2024-06-20fix(ext/node): use cppgc for node:zlib (#24267)Divy Srivastava
2024-06-19fix(ext/node): Add Dirent.path and Dirent.parentPath (#24257)Divy Srivastava
2024-06-18fix(ext/node): make process.versions own property (#24240)Divy Srivastava
2024-06-18feat(ext/node): add BlockList & SocketAddress classes (#24229)Satya Rohith
Closes https://github.com/denoland/deno/issues/24059
2024-06-17fix(ext/node): use `Deno.FsFile.statSync()` (#24234)Asher Gomez
2024-06-14fix(ext/node): `server.close()` does graceful shutdown (#24184)Divy Srivastava
2024-06-12fix(ext/node): fix vm memory usage and context initialization (#23976)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/22441 Fixes https://github.com/denoland/deno/issues/23913 Fixes https://github.com/denoland/deno/issues/23852 Fixes https://github.com/denoland/deno/issues/23917
2024-06-11fix(ext/node): ServerResponse header array handling (#24149)Luca Casonato
Previously res.setHeader("foo", ["bar", "baz"]) added a single header with a value of `bar,baz`. Really this should add two separate headers. This is visible in `set-cookie` for example.
2024-06-05chore: upgrade dlint to 0.60.0 (#24041)Bartek Iwańczuk
Factoring out `dlint` upgrade from https://github.com/denoland/deno/pull/24034 as it requires us to change the lint step on mac to use ARM runners. --------- Co-authored-by: Luca Casonato <hello@lcas.dev> Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-06-02fix: validate integer values in `Deno.exitCode` setter (#24068)Kenta Moriuchi
2024-05-29feat: Add `Deno.exitCode` API (#23609)Luke Edwards
This commits adds the ability to set a would-be exit code for the Deno process without forcing an immediate exit, through the new `Deno.exitCode` API. - **Implements `Deno.exitCode` getter and setter**: Adds support for setting and retrieving a would-be exit code via `Deno.exitCode`. This allows for asynchronous cleanup before process termination without immediately exiting. - **Ensures type safety**: The setter for `Deno.exitCode` validates that the provided value is a number, throwing a TypeError if not, to ensure that only valid exit codes are set. Closes to #23605 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-29fix(ext/node): don't encode buffer data as utf8 in http2 (#24016)Satya Rohith
2024-05-28fix(ext/node/fs): `position` argument not applied (#24009)Marvin Hagemeister
We didn't honour the `position` options of `fd.read` and `fd.write` because we checked if the buffer is of type `Buffer` instead of just `Uint8Array`. Node does the latter. In doing so I noticed that the file handle id was written to a public property which it definitely shouldn't be. This was probably a typo. Fixes https://github.com/denoland/deno/issues/23707
2024-05-28fix(ext/node): add `throwIfNoEntry` option in `fs.lstatSync` (#24006)Marvin Hagemeister
We didn't support the `throwIfNoEntry` option for Node's `fs.lstatSync` method. Note that the async variant doesn't have this option. Fixes https://github.com/denoland/deno/issues/23996
2024-05-26fix(node): set default http server response code 200 (#23977)Marvin Hagemeister
Node sets the default HTTP response status code to 200 on the `ServerResponse`. We initialised it as `undefined` before which caused a problem with 11ty's dev server. Thanks to @vrugtehagel for reporting this issue and finding the correct fix as well 🎉 Fixes https://github.com/denoland/deno/issues/23970
2024-05-23fix(ext/node): add stubs for perf_hooks.PerformaceObserver (#23958)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/23943
2024-05-23feat(ext/fetch): `Request.bytes()` and `Response.bytes()` (#23823)Asher Gomez
Closes #23790