0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-15 10:06:23 -05:00
Commit graph

1110 commits

Author SHA1 Message Date
Divy Srivastava
1cbaee9f52
fix(ext/node): sqlite bind support bigint values (#27890) 2025-01-31 18:31:05 +05:30
Yoshiya Hinosawa
1cecc0a8b0
fix(ext/node): support proxy http request (#27871) 2025-01-31 21:46:54 +09:00
Divy Srivastava
057f257052
fix(ext/node): represent sqlite blob as Uint8Array (#27889) 2025-01-31 17:53:48 +05:30
Divy Srivastava
08cc22105f
fix(ext/node): set process.env as own property (#27891)
Fixes `gcp-metadata@6.1.1`

```
% deno eval "import 'npm:gcp-metadata@6.1.1'" # main
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')
    at Object.log (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:52:20)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:409:4)
    at Module._compile (node:module:745:34)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:755:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)

% target/debug/deno eval "import 'npm:gcp-metadata@6.1.1'" # this PR
```

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2025-01-31 11:38:26 +05:30
denobot
d9db0b35e0
chore: forward v2.1.9 release commit to main (#27888)
This is the release commit being forwarded back to main for 2.1.9

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-31 03:02:00 +01:00
Nathan Whitaker
bac8171c40
perf(crypto): use ring for asm implementations of sha256/sha512 (#27885)
Currently we are using the pure rust backend of `sha2`, which has subpar
performance compared to asm implementations. We already depend on
`ring`, so just use that instead of `sha2` for sha256/sha512 digests.

This also speeds up things like S3 uploads, which calculate sha digests
of the uploaded objects. On my local machine, this speeds up uploading a
100MB file (to a localhost s3 provider via`@aws-sdk/client-s3`) by about
2x

<details>

<summary>Benchmark:</summary>

```ts
import { createHmac } from "node:crypto";

for (
  const size of [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000]
) {
  const input = "a".repeat(size);
  Deno.bench({
    name: `sha256-${size}`,
    fn() {
      const _hash = createHmac("sha256", input).update(input).digest();
    },
  });
  Deno.bench({
    name: `sha512-${size}`,
    fn() {
      const _hash = createHmac("sha512", input).update(input).digest();
    },
  });
}
```

</details>

<details>

<summary>Results (arm64 macOS):</summary>

```
--- sha256-1 ---
../../deno/target/release/deno         2.527 µs    1.240 times faster
/Users/nathanwhit/.deno/bin/deno       3.132 µs    
--- sha512-1 ---
../../deno/target/release/deno         3.364 µs    1.071 times faster
/Users/nathanwhit/.deno/bin/deno       3.603 µs    
--- sha256-10 ---
../../deno/target/release/deno         3.060 µs    1.027 times faster
/Users/nathanwhit/.deno/bin/deno       3.144 µs    
--- sha512-10 ---
../../deno/target/release/deno         3.583 µs    1.047 times faster
/Users/nathanwhit/.deno/bin/deno       3.751 µs    
--- sha256-100 ---
../../deno/target/release/deno         3.695 µs    1.244 times faster
/Users/nathanwhit/.deno/bin/deno       4.598 µs    
--- sha512-100 ---
../../deno/target/release/deno         3.386 µs    1.188 times faster
/Users/nathanwhit/.deno/bin/deno       4.021 µs    
--- sha256-1000 ---
../../deno/target/release/deno         4.007 µs    3.230 times faster
/Users/nathanwhit/.deno/bin/deno      12.944 µs    
--- sha512-1000 ---
../../deno/target/release/deno         6.463 µs    1.466 times faster
/Users/nathanwhit/.deno/bin/deno       9.477 µs    
--- sha256-10000 ---
../../deno/target/release/deno        11.674 µs    6.981 times faster
/Users/nathanwhit/.deno/bin/deno      81.493 µs    
--- sha512-10000 ---
../../deno/target/release/deno        31.250 µs    1.740 times faster
/Users/nathanwhit/.deno/bin/deno      54.364 µs    
--- sha256-100000 ---
../../deno/target/release/deno        82.800 µs    9.393 times faster
/Users/nathanwhit/.deno/bin/deno     777.719 µs    
--- sha512-100000 ---
../../deno/target/release/deno       269.726 µs    1.851 times faster
/Users/nathanwhit/.deno/bin/deno     499.243 µs    
--- sha256-1000000 ---
../../deno/target/release/deno       808.662 µs    9.427 times faster
/Users/nathanwhit/.deno/bin/deno       7.623 ms    
--- sha512-1000000 ---
../../deno/target/release/deno         2.672 ms    1.795 times faster
/Users/nathanwhit/.deno/bin/deno       4.795 ms    
--- sha256-10000000 ---
../../deno/target/release/deno         7.823 ms    9.868 times faster
/Users/nathanwhit/.deno/bin/deno      77.201 ms    
--- sha512-10000000 ---
../../deno/target/release/deno        26.197 ms    1.846 times faster
/Users/nathanwhit/.deno/bin/deno      48.356 ms    
```

</details>

<details>

<summary>Results (x86_64 linux):</summary>

```
--- sha256-1 ---
/home/nathanwhit/.deno/bin/deno             10.726 µs    1.229 times faster
../../../deno/target/release-lite/deno      13.184 µs    
--- sha512-1 ---
/home/nathanwhit/.deno/bin/deno             13.177 µs    1.051 times faster
../../../deno/target/release-lite/deno      13.845 µs    
--- sha256-10 ---
/home/nathanwhit/.deno/bin/deno             13.156 µs    1.047 times faster
../../../deno/target/release-lite/deno      13.780 µs    
--- sha512-10 ---
/home/nathanwhit/.deno/bin/deno             14.386 µs    1.029 times faster
../../../deno/target/release-lite/deno      14.807 µs    
--- sha256-100 ---
/home/nathanwhit/.deno/bin/deno             14.580 µs    1.083 times faster
../../../deno/target/release-lite/deno      15.789 µs    
--- sha512-100 ---
/home/nathanwhit/.deno/bin/deno             13.477 µs    1.131 times faster
../../../deno/target/release-lite/deno      15.238 µs    
--- sha256-1000 ---
../../../deno/target/release-lite/deno      17.208 µs    1.116 times faster
/home/nathanwhit/.deno/bin/deno             19.198 µs    
--- sha512-1000 ---
../../../deno/target/release-lite/deno      21.168 µs    1.026 times faster
/home/nathanwhit/.deno/bin/deno             21.717 µs    
--- sha256-10000 ---
../../../deno/target/release-lite/deno      33.586 µs    1.990 times faster
/home/nathanwhit/.deno/bin/deno             66.837 µs    
--- sha512-10000 ---
../../../deno/target/release-lite/deno      53.338 µs    1.009 times faster
/home/nathanwhit/.deno/bin/deno             53.817 µs    
--- sha256-100000 ---
../../../deno/target/release-lite/deno     168.238 µs    3.063 times faster
/home/nathanwhit/.deno/bin/deno            515.354 µs    
--- sha512-100000 ---
../../../deno/target/release-lite/deno     383.311 µs    1.036 times faster
/home/nathanwhit/.deno/bin/deno            397.122 µs    
--- sha256-1000000 ---
../../../deno/target/release-lite/deno       1.474 ms    3.471 times faster
/home/nathanwhit/.deno/bin/deno              5.115 ms    
--- sha512-1000000 ---
../../../deno/target/release-lite/deno       3.658 ms    1.057 times faster
/home/nathanwhit/.deno/bin/deno              3.865 ms    
--- sha256-10000000 ---
../../../deno/target/release-lite/deno      16.438 ms    3.136 times faster
/home/nathanwhit/.deno/bin/deno             51.556 ms    
--- sha512-10000000 ---
../../../deno/target/release-lite/deno      37.128 ms    1.056 times faster
/home/nathanwhit/.deno/bin/deno             39.220 ms    
```

</details>
2025-01-30 23:38:14 +00:00
denobot
1b7719c5d6
chore: forward v2.1.8 release commit to main (#27882)
This is the release commit being forwarded back to main for 2.1.8

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 21:09:06 +01:00
Cyan
e6dda60d5c
feat: implement process.cpuUsage (Deno.cpuUsage) (#27217) 2025-01-30 17:23:05 +05:30
Divy Srivastava
79fa6028d1
fix(ext/node): implement crypto.hash (#27858)
Implement
[`crypto.hash`](https://nodejs.org/api/crypto.html#cryptohashalgorithm-data-outputencoding)
- one-shot version of `createHash`

Fixes #24945
2025-01-29 20:49:43 +05:30
snek
02ed300525
feat(node:http): add http information support (#27381)
Implements some client and server events to improve compat.

Fixes: https://github.com/denoland/deno/issues/27239
2025-01-28 17:37:53 +00:00
Divy Srivastava
aeac5a6338
feat(ext/node): implement node:sqlite (#27308)
Depends on:
- https://github.com/denoland/deno_core/pull/994
- https://github.com/denoland/deno_core/pull/993
- https://github.com/denoland/deno_core/issues/999
- https://github.com/denoland/deno_core/pull/1000
- https://github.com/denoland/deno_core/pull/1001

Closes https://github.com/denoland/deno/issues/24828


![image](https://github.com/user-attachments/assets/396fc8b7-30cb-411c-82bc-2e9e3e6bbb18)

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2025-01-28 19:30:03 +05:30
Nathan Whitaker
094e268002
fix(ext/node): implement aes-128-ctr, aes-192-ctr, and aes-256-ctr (#27630)
Fixes https://github.com/denoland/deno/issues/24864

Need to add some tests, also unsure about the right counter size (went
with 128 bit to be safe)

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2025-01-27 23:35:51 -08:00
Yoshiya Hinosawa
0e47205ebe
fix(ext/node): do not apply socket-init-workaround to ipc socket (#27779)
This PR resolves 2 issues of Socket class of node compat (both are
related to playwright)

Currently `browser.launch()` of playwright is not working.
`browser.launch` opens PipeTransport (which is based on Pipe/IPC socket)
with the browser process. But that pipe doesn't start reading the data
because of the workaround #27662 (which pauses the socket at the
beginning if it's from playwright-core). This PR fixes this issue by
checking whether the given handle is `ipc` handle or not.

Another issue is that sock-init-workaround for TLS connection stopped
working at #27707 because of the changes of TLS socket initialization
steps. This change fixes the issue by correctly returning the function
in workaround path.

The added case `specs::npm::playwright_compat` checks both fixes with
actual playwright and playwright-core packages.

`browser.launch` issues
closes #16899
closes #27623 

`https.request` issue
closes #27658
2025-01-28 15:38:45 +09:00
David Sherret
679902a108
perf(node_resolver): reduce url to/from path conversions (#27839)
Extracted out of https://github.com/denoland/deno/pull/27838/files

Reduces some allocations by accepting either a pathbuf or url for the
referrer for resolution and returning either a pathbuf or url at the
end, which the caller can then convert into to their preferred state.

This is about 4% faster when still converting the final result to a url
and 6% faster when keeping the result as a path in a benchmark I ran.
2025-01-27 15:23:20 -05:00
Divy Srivastava
533993efcf
fix(ext/node): implement X509Certificate#checkHost (#27821)
Fixes https://github.com/denoland/deno/issues/27619
2025-01-27 16:33:03 +05:30
Divy Srivastava
f678a17313
fix(ext/node): fix panic when invalid AES GCM key size (#27818)
Fixes https://github.com/denoland/deno/issues/27807
2025-01-27 16:32:25 +05:30
Divy Srivastava
a2d0872225
fix(ext/node): fix async variant of brotliDecompress (#27815)
Fixes https://github.com/denoland/deno/issues/27729
2025-01-27 09:13:47 +05:30
Divy Srivastava
802b9d6309
chore(ext/node): remove internal/streams/buffer_list.mjs (#27822)
This was never used internally and not supposed to be public either.
2025-01-27 09:13:06 +05:30
Divy Srivastava
1efc77331c
fix(ext/node): scrypt panic when log_n > 64 (#27816)
Throws an error instead of panic. Ref
https://github.com/denoland/deno/issues/27716
2025-01-27 09:12:51 +05:30
Yoshiya Hinosawa
2511458ac1
fix(ext/node): npm:mqtt compatibility (#27792) 2025-01-27 11:47:32 +09:00
David Sherret
273ec9fbf2
refactor: add WorkspaceFactory and ResolverFactory (#27766)
Allows easily constructing a `DenoResolver` using the exact same logic
that we use in the CLI (useful for dnt and for external bundlers). This
code is then used in the CLI to ensure the logic is always up-to-date.

```rs
use std::rc::Rc;

use deno_resolver:🏭:ResolverFactory;
use deno_resolver:🏭:WorkspaceFactory;
use sys_traits::impls::RealSys;

let sys = RealSys;
let cwd = sys.env_current_dir()?;
let workspace_factory = Rc::new(WorkspaceFactory::new(sys, cwd, Default::default()));
let resolver_factory = ResolverFactory::new(workspace_factory.clone(), Default::default());
let deno_resolver = resolver_factory.deno_resolver().await?;
```
2025-01-23 18:52:55 -05:00
Divy Srivastava
f3c0bbf926
fix(ext/node): reference error in zlib.crc32 (#27777)
Fixes https://github.com/denoland/deno/issues/27774
2025-01-22 14:31:17 +00:00
Yoshiya Hinosawa
773825aeb9
fix(ext/node): fix formatting of debug logs (#27772) 2025-01-22 20:13:13 +09:00
denobot
3ba212649f
chore: forward v2.1.7 release commit to main (#27767)
This is the release commit being forwarded back to main for 2.1.7

Please ensure:
- [x] Everything looks ok in the PR
- [x] The release has been published

To make edits to this PR:
```shell
git fetch upstream forward_v2.1.7 && git checkout -b forward_v2.1.7 upstream/forward_v2.1.7
```

Don't need this PR? Close it.

cc @crowlKats

---------

Co-authored-by: crowlKats <crowlKats@users.noreply.github.com>
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2025-01-21 19:25:12 -08:00
ZYSzys
4e0bf4b093
fix(ext/node): add FileHandle#sync (#27677) 2025-01-21 14:52:40 +09:00
Divy Srivastava
4f27d7cdc0
fix(ext/node): GCM auth tag check on DechiperIv#final (#27733) 2025-01-20 18:16:44 +05:30
David Sherret
57dd66ec3d
refactor: move denort to separate crate (#27688)
This slightly degrades the performance of CJS export analysis on
subsequent runs because I changed it to no longer cache in the DENO_DIR
with this PR (denort now properly has no idea about the DENO_DIR). We'll
have to change it to embed this data in the binary and that will also
allow us to get rid of swc in denort (will do that in a follow-up PR).
2025-01-17 20:39:29 +00:00
Leo Kettmeir
054075730c
refactor: update deno_core and use more concrete errors (#27620)
waiting for https://github.com/denoland/deno_core/pull/1043

Fixes #27672
2025-01-17 09:41:52 -08:00
Yoshiya Hinosawa
b55451b178
fix(ext/node): tls.connect regression (#27707)
The TLS start sequence has been broken since #26661 because of the way
how we wrap TCP handle to create TLS handle.

#26661 introduced happy-eyeballs algorithm and some connection could be
dropped because of happy-eyeball attempt timeout. The current
implementation doesn't consider that case and it could start TLS
handshake with timed out TCP connection. That caused #27652 .

This PR fixes it by changing the initialization steps. Now `wrapHandle`
of TLSSocket set up `afterConnectTls` callback in TCP handle, and
`afterConnect` of TCP handle calls it at `connect` event timing if it
exists. This avoids starting TLS session with timed out connection.

closes #27652
2025-01-18 00:10:26 +09:00
Bartek Iwańczuk
0050857f51
refactor: add 'deno_process' crate (#27680)
Untangled the whole `runtime/ops/process.rs` from `ext/node/` and moved
to a separate `ext/process` crate.
2025-01-17 13:30:14 +01:00
Yoshiya Hinosawa
339bc44c58
fix(ext/node): propagate socket error to client request object (#27678)
Co-authored-by: Satya Rohith <me@satyarohith.com>
2025-01-17 12:30:00 +09:00
denobot
94dc5b16f5
chore: forward v2.1.6 release commit to main (#27705)
This is the release commit being forwarded back to main for 2.1.6

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-17 02:09:13 +01:00
Masato Yoshioka
b22a50cb0c
fix(ext/node): add chown method to FileHandle class (#27638) 2025-01-15 17:15:07 +09:00
Bartek Iwańczuk
974e2f44b2
refactor: add 'deno_os' crate (#27655)
This commit creates "deno_os" extension crate and moves
numerous ops from "runtime/" crate to the new crate.
2025-01-14 17:29:36 +01:00
Yoshiya Hinosawa
c943f56949
fix(ext/node): fix playwright http client (#27662) 2025-01-15 01:00:55 +09:00
David Sherret
0b033140c0
refactor: move CliNpmResolver to deno_resolver::npm::NpmResolver (#27659)
As title. After this PR all npm resolution will be out of the CLI crate.
2025-01-14 10:01:05 -05:00
siaeyy
a1f50a7422
fix(node/fs): add utimes method to the FileHandle class (#27582) 2025-01-14 18:08:22 +09:00
Aaron Ang
9cb089f6db
fix(ext/node): add writev method to FileHandle (#27563)
Part of #25554
2025-01-14 18:01:14 +09:00
TateKennington
5a39f2f096
fix(node): Prevent node:child_process from always inheriting the parent environment (#27343) (#27340)
Fixes #27343

Currently the node:child_process polyfill is always passing the full
parent environment to all spawned subprocesses. In the case where
`options.env` is provided those keys are overridden but the rest of the
parent environment is still passed through.

On Node the behaviour is for child processes to only inherit the parent
environment when `options.env` isn't specified. When `options.env` is
specified the child process inherits only those keys.

This PR updates the internal node child_process polyfill so that the
`clearEnv` argument is set to true when spawning the subprocess to
prevent the parent environment always being inherited by default. It
also fixes an issue where `normalizeSpawnArguments` wasn't returning the
`env` option if `options.env` was unset.
2025-01-13 13:46:56 -08:00
Yoshiya Hinosawa
2091691164
fix(ext/node): apply @npmcli/agent workaround to npm-check-updates (#27639)
See the comment
https://github.com/denoland/deno/pull/25470#issuecomment-2435077722 for
the reason why we do this workaround to make `make-fetch-happen` work in
Deno

This PR applies the same workaround to `npm-check-updates` package.
`npm-check-updates` internally uses
[`npm-registry-fetch`](https://www.npmjs.com/package/npm-registry-fetch)
which uses
[`make-fetch-happen`](https://www.npmjs.com/package/make-fetch-happen)
(the problematic package) for making http request to npm registry.

The detection of `make-fetch-happen` doesn't work for
`npm-check-updates` because we use call stack at `net.Socket`
constructor to check if it's called from `make-fetch-happen`, but
`npm-check-updates` bundles its dependency and the check doesn't work.

This PR adds the check of `npm-check-updates` string in call stack in
net.Socket constructor to trigger the workaroud.

closes #27629
2025-01-13 18:11:26 +09:00
Rajhans Jadhao
1dd5bd667c
fix(ext/node): use primordials in ext/node/polyfills/_fs_common.ts (#27589)
Related to #24236
2025-01-10 13:51:50 +01:00
denobot
8bafb182ef
chore: forward v2.1.5 release commit to main (#27613)
Co-authored-by: dsherret <dsherret@users.noreply.github.com>
2025-01-09 17:38:18 -05:00
Leo Kettmeir
ea30e188a8
refactor: update deno_core for error refactor (#26867)
Closes #26171

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2025-01-08 14:52:32 -08:00
Divy Srivastava
fffa3804aa
fix(ext/node): Fix os.cpus() on Linux (#27592)
Populate `speed` using current scaling frequency and fix times
multiplier.

Fixes https://github.com/denoland/deno/issues/27555

<table>
<tr>
<th>Node.js</th>
<th>Deno</th>
</tr>
<tr>
<td>

```
> os.cpus()
[
  {
    model: 'AMD Ryzen 5 7530U with Radeon Graphics',
    speed: 1396,
    times: {
      user: 1769930,
      nice: 20,
      sys: 525630,
      idle: 41325700,
      irq: 110060
    }
  },
```

</td>
<td>

```
> os.cpus()
[
  {
    model: "AMD Ryzen 5 7530U with Radeon Graphics",
    speed: 1630,
    times: [Object: null prototype] {
      user: 1795620,
      nice: 20,
      sys: 537840,
      idle: 41589390,
      irq: 111230
    }
  },
```

</td>
</tr>
</table>
2025-01-08 22:09:55 +05:30
Yusuke Tanaka
1661ddd9ca
fix(ext/node): have process global available in Node context (#27562)
This commit makes `process` global always available in Node context.

`process` global was previously available explicitly in `deno_node`, but then
got removed in #25291 and made globally available regardless of whether it's in
Deno or Node context, so this commit does not have any effect on Deno CLI.
However, for users who want to use `deno_node` ext only, it makes sense to have
`process` available to simulate the Node environment individually.

This change may bring some negative performance impact. To measure how large the
impact would be, a very simple benchmark was performed whose results can be
found at https://github.com/magurotuna/process_global_bench.
2025-01-08 13:14:57 +09:00
Nikolay Karadzhov
8cda4cf53d
feat(node/fs): Add a chmod method to the FileHandle class (#27522)
Add the chmod method to the FileHandle class in node compat as part of
#25554
2025-01-07 14:58:14 +01:00
David Sherret
0457c38d4f
refactor: remove use of home crate (#27516)
The two places mentioned in the issue are now consolidated.

Closes https://github.com/denoland/deno/issues/24385
2025-01-02 10:06:35 -05:00
Kenta Moriuchi
8fb073d7b4
chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
David Sherret
ac7b33a340
chore: cargo fmt - turn on group_imports=StdExternalCrate (#26646) 2024-12-31 12:13:39 -05:00
David Sherret
4638caa740
refactor: do not use deno_fs::FileSystem everywhere (#27508)
This changes the cli to mostly use `std::fs` via `sys_traits` instead of
the implemention of `deno_fs::FileSystem`.
2024-12-31 11:29:07 -05:00