1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
Commit graph

897 commits

Author SHA1 Message Date
Satya Rohith
65224786d2
fix(ext/node): client closing streaming request shouldn't terminate http server (#24946)
Closes https://github.com/denoland/deno/issues/22820
2024-08-08 10:22:58 +00:00
Birk Skyum
733162a83e
fix(node/crypto): Assign publicKey and privateKey with let instead of const (#24943)
Because public/private key are reassigned, they should be `let` instead
of `const`.

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-08-08 15:50:16 +05:30
Luca Casonato
93d479252b
fix(ext/node): add crypto.diffieHellman (#24938)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>

Closes #21806
2024-08-08 15:05:29 +05:30
Marvin Hagemeister
9d6da1036d
fix: rename watch event missing (#24893)
This PR ensures that we forward a `rename` event in our file watcher.
The rust lib we use combines that with the `modify` event.

This fixes a compatibility issue with Node too, which sends the `rename`
event as well.

Fixes https://github.com/denoland/deno/issues/24880
2024-08-07 18:15:57 +02:00
Luca Casonato
4fa8869f24
feat(ext/node): rewrite crypto keys (#24463)
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-07 08:43:58 +02:00
snek
897159dc6e
feat: vm rewrite (#24596)
rewrite vm implementation to increase compat.
vm.Module+importModuleDynamically callbacks should be added in a
followup.
2024-08-06 12:52:53 +00:00
Nathan Whitaker
ae8d048b6c
fix(node): Fix node IPC serialization for objects with undefined values (#24894)
We were serializing `{ a: undefined }` to `{ a: null }` instead of `{}`
2024-08-05 09:42:26 -07:00
snek
649725442a
feat: upgrade deno_core (#24886)
Fixes: https://github.com/denoland/deno/issues/24869

Includes changes for `node:vm` rewrite.
2024-08-05 08:28:12 -07:00
snek
71ca61e189
Revert "feat: async context" (#24856)
Reverts denoland/deno#24402

deno_web can't depend on code in runtime
2024-08-02 18:16:59 +00:00
snek
3a1a1cc030
feat: async context (#24402)
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-02 08:14:35 -07:00
Bartek Iwańczuk
b82a2f114c
fix(ext/node): node:zlib coerces quality 10 to 9.5 (#24850)
Fixes https://github.com/denoland/deno/issues/24572
2024-08-02 16:44:32 +02:00
Luca Casonato
7495bcbf77
Revert "perf(ext/node): improve Buffer from string performance" (#24851) 2024-08-02 16:23:21 +02:00
Andreas Deininger
ea121c9a0e
docs: fix typos (#24820)
This PR fixes various typos I spotted in the project.
2024-08-02 13:26:54 +02:00
Bartek Iwańczuk
5c54dc5840
fix: regressions around Error.prepareStackTrace (#24839)
Includes:
- https://github.com/denoland/deno_core/pull/858
- https://github.com/denoland/deno_core/pull/856

Fixes https://github.com/denoland/deno/issues/24782
Fixes https://github.com/denoland/deno/issues/24825
2024-08-01 22:15:20 +00:00
Luca Casonato
f1fc708d81
fix(ext/crypto): respect offsets when writing into ab views in randomFillSync (#24816) 2024-08-01 09:38:46 +02:00
snek
f57745fe21
feat: upgrade V8 to 12.8 (#24693)
- upgrade to v8 12.8
  - optimizes DataView bigint methods
  - fixes global interceptors
  - includes CPED methods for ALS
- fix global resolution
- makes global resolution consistent using host_defined_options.
originally a separate patch but due to the global interceptor bug it
needs to be included in this pr for all tests to pass.
2024-07-31 23:22:34 +00:00
denobot
6267905f09
chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
Luca Casonato
1faac2dce3
fix(ext/node): handle node child_process with --v8-options flag (#24804)
Makes `v8flags` package from NPM work.
2024-07-31 16:28:08 +02:00
Marvin Hagemeister
9e6288ec61
fix(node/fs/promises): watch should be async iterable (#24805)
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-31 13:07:49 +02:00
Marvin Hagemeister
1e2581e57b
fix(node/timers/promises): add scheduler APIs (#24802)
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-31 12:00:01 +02:00
Nathan Whitaker
cd59fc53a5
fix(node): Rework node:child_process IPC (#24763)
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-30 16:13:24 -07:00
Divy Srivastava
1ba88a7892
perf(ext/node): improve Buffer from string performance (#24567)
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-30 18:09:55 +05:30
Bartek Iwańczuk
c6ecf70a09
refactor(ext/node): create separate ops for node:http module (#24788)
This commit duplicates ops from "ext/fetch" to "ext/node" to
kick off a bigger rewrite of "node:http".

Most of duplication is temporary and will be removed as these
ops evolve.
2024-07-30 14:34:52 +02:00
Satya Rohith
8bab761bcc
fix(ext/node): prevent panic in http2.connect with uppercase header names (#24780)
Closes https://github.com/denoland/deno/issues/24678
2024-07-29 13:33:55 +02:00
David Sherret
50fa4d7ef5
fix: actually add missing node:readline/promises module (#24772)
Closes #24768
2024-07-28 15:41:10 -04:00
denobot
ed2bf8ce31
chore: forward v1.45.4 release commit to main (#24754)
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-07-26 14:26:13 -04:00
MrEconomical
f4952f75a8
fix(ext/node): read correct CPU usage stats on Linux (#24732)
Fixes #24731

<img width="554" alt="deno_fixed"
src="https://github.com/user-attachments/assets/691f2f89-d979-4ca5-be9a-cf51446cd9b2">

The total CPU usage row is ignored and info from `cpu0` and `cpu1` is
correctly read.

---------

Signed-off-by: MrEconomical <47700125+MrEconomical@users.noreply.github.com>
2024-07-26 09:09:01 +05:30
David Sherret
3bf147fe28
refactor: decouple node resolution from deno_core (#24724) 2024-07-25 19:08:14 -04:00
Marvin Hagemeister
0cf7f268a7
fix(node/worker_threads): support port.once() (#24725)
Support `MessagePort.once` in Node mode and enable relevant
`worker_threads` test. Noticed that another Node test was passing as
well, so I enabled that too.
2024-07-25 23:06:19 +02:00
Bartek Iwańczuk
1fad6eb2ac
fix(ext/fetch): respect authority from URL (#24705)
This commit fixes handling of "authority" in the URL by properly
sending "Authorization Basic..." header in `fetch` API.

This is a regression from https://github.com/denoland/deno/pull/24593
Fixes https://github.com/denoland/deno/issues/24697

CC @seanmonstar
2024-07-24 23:22:43 +02:00
Yoshiya Hinosawa
199a8ca4c5
fix(ext/node/net): emit error before close when connection is refused (#24656) 2024-07-24 20:33:45 +09:00
Nathan Whitaker
29934d558c
fix(node): Run node compat tests listed in the ignore field (and fix the ones that fail) (#24631)
The intent is that those tests will be executed, but our check that the
files are up to date won't overwrite the contents of the tests. This is
useful when a test needs some manual edits to work.

It turns out we weren't actually running them.

---

This ended up turning into a couple of small bug fixes to get the tests
passing:

- We weren't canonicalizing the exec path properly (it sometimes still
had `..` or `.` in it)
- We weren't accepting strings in `process.exit`

There was one failure I couldn't figure out quickly, so I disabled the
test for now, and filed a follow up issue: #24694
2024-07-24 03:12:08 +00:00
David Sherret
52ababc4bf
fix(node): better detection for when to surface node resolution errors (#24653) 2024-07-24 00:22:24 +00:00
David Sherret
6055629ee7
refactor: update to use deno_package_json (#24688)
This is in preparation for extracting out node resolution code from
ext/node (which is something I'm going to do gradually over time).

Uses https://github.com/denoland/deno_package_json
2024-07-23 17:34:46 -04:00
denobot
9806064ac2
chore: forward v1.45.3 release commit to main (#24681)
This is the release commit being forwarded back to main for 1.45.3

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-23 03:41:40 +02:00
Marvin Hagemeister
c77b8b96ef
fix: missing emitWarning import (#24587)
We were missing an import of `emitWarning` in our streams
implementation. The code prior to this PR assumed that `process` would
be available as a global.

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

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-19 23:35:07 +00:00
Marvin Hagemeister
ee2e693340
fix(node): support tty.hasColors() and tty.getColorDepth() (#24619)
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-19 12:39:05 +02:00
Yoshiya Hinosawa
76b8ecbb6d
fix(ext/node): do not expose self global in node (#24637)
closes #23727
2024-07-19 12:37:08 +09:00
Divy Srivastava
bf9c08b705
fix(ext/node): stat.mode on windows (#24434) 2024-07-17 19:43:40 -07:00
Bartek Iwańczuk
7b33623b1d
Reland "refactor(fetch): reimplement fetch with hyper instead of reqwest" (#24593)
Originally landed in
f6fd6619e7.
Reverted in https://github.com/denoland/deno/pull/24574.

This reland contains a fix that sends "Accept: */*" header for calls made
from "FileFetcher". Absence of this header made downloading source code
from JSR broken. This is tested by ensuring this header is present in the
test server that servers JSR packages.

---------

Co-authored-by: Sean McArthur <sean@seanmonstar.com>
2024-07-18 01:37:31 +02:00
Divy Srivastava
078def0ff8
perf(ext/node): optimize fs.exists[Sync] (#24613)
Use `access` on *nix and `GetFileAttributesW` on Windows.

[Benchmark](https://paste.divy.work/p/-gq8Ark.js):
```
$ deno run -A bench.mjs # main (568dd)
existsSync: 8980.636629ms

$ target/release/deno run -A bench.mjs # this PR
existsSync: 6448.7604519999995ms

$ bun bench.mjs
existsSync: 6562.88671ms

$ node bench.mjs
existsSync: 7740.064653ms
```

Ref https://github.com/denoland/deno/pull/24434#discussion_r1679777912
2024-07-17 18:05:51 +05:30
David Sherret
568dd132fb
refactor(node): internally add .code() to node resolution errors (#24610)
This makes it easier to tell what kind of error something is (even for
deeply nested errors) and will help in the future once we add error
codes to the JS errors this returns.
2024-07-16 18:32:41 -04:00
Satya Rohith
6421dc33ed
fix(ext/node): http request uploads of subarray of buffer should work (#24603)
Closes https://github.com/denoland/deno/issues/24571
2024-07-16 14:16:40 +02:00
snek
70a9631696
chore: upgrade dependencies (#24565)
rustls + hyper + deno_core
2024-07-15 09:56:51 -07:00
Rano | Ranadeep
702f7ee89c
fix(std/http2): release window capacity back to remote stream (#24576)
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-15 17:10:59 +05:30
Ryan Dahl
e0cfc9da39
Revert "refactor(fetch): reimplement fetch with hyper instead of reqwest (#24237)" (#24574)
This reverts commit f6fd6619e7.

I'm seeing a difference between canary and 1.45.2. In
`deno-docs/reference_gen` I can't download dax when running `deno task
types`

```
~/src/deno-docs/reference_gen# deno upgrade --canary
Looking up latest canary version
Found latest version f6fd6619e7
Downloading https://dl.deno.land/canary/f6fd6619e708a515831f707438368d81b0c9aa56/deno-aarch64-apple-darwin.zip
Deno is upgrading to version f6fd6619e7
Archive:  /var/folders/9v/kys6gqns6kl8nksyn4l1f9v40000gn/T/.tmpb5lDnq/deno.zip
  inflating: deno
Upgraded successfully

~/src/deno-docs/reference_gen# deno -v
deno 1.45.2+f6fd661

~/src/deno-docs/reference_gen# rm -rf /Users/ry/Library/Caches/deno

~/src/deno-docs/reference_gen# deno task types
Task types deno task types:deno && deno task types:node
Task types:deno deno run --allow-read --allow-write --allow-run --allow-env --allow-sys deno-docs.ts
error: JSR package manifest for '@david/dax' failed to load. expected value at line 1 column 1
    at file:///Users/ry/src/deno-docs/reference_gen/deno-docs.ts:2:15

~/src/deno-docs/reference_gen# deno upgrade --version 1.45.2
Downloading https://github.com/denoland/deno/releases/download/v1.45.2/deno-aarch64-apple-darwin.zip
Deno is upgrading to version 1.45.2
Archive:  /var/folders/9v/kys6gqns6kl8nksyn4l1f9v40000gn/T/.tmp3R7uhF/deno.zip
  inflating: deno
Upgraded successfully

~/src/deno-docs/reference_gen# rm -rf /Users/ry/Library/Caches/deno

~/src/deno-docs/reference_gen# deno task types
Task types deno task types:deno && deno task types:node
Task types:deno deno run --allow-read --allow-write --allow-run --allow-env --allow-sys deno-docs.ts
Task types:node deno run --allow-read --allow-write=. --allow-env --allow-sys node-docs.ts
```
2024-07-13 21:08:23 +00:00
Sean McArthur
f6fd6619e7
refactor(fetch): reimplement fetch with hyper instead of reqwest (#24237)
This commit re-implements `ext/fetch` and all dependent crates
using `hyper` and `hyper-util`, instead of `reqwest`.

The reasoning is that we want to have greater control and access
to low level `hyper` APIs when implementing `fetch` API as well
as `node:http` module.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-13 00:51:37 +02:00
denobot
3a48bc695f
chore: forward v1.45.2 release commit to main (#24564)
Co-authored-by: dsherret <dsherret@users.noreply.github.com>
2024-07-12 18:05:45 -04:00
Satya Rohith
8cbf81cf08
fix(ext/node): handle prefix mapping for IPv4-mapped IPv6 addresses (#24546)
Ensure that the prefix is properly adjusted when dealing with IPv4
addresses mapped to IPv6. This fixes inconsistencies in network
range calculations for mapped addresses.

Closes https://github.com/denoland/deno/issues/24525
2024-07-12 14:25:17 +05:30
snek
7ab25dd89e
fix: unblock fsevents native module (#24542)
node-api is fully supported now.

Signed-off-by: snek <snek@deno.com>
2024-07-11 19:15:05 -07:00
denobot
0be4c8947d
chore: forward v1.45.1 release commit to main (#24540)
This is the release commit being forwarded back to main for 1.45.1

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2024-07-12 01:14:14 +02:00
David Sherret
1200f69082
fix(node): revert invalid package target change (#24539)
Reason is that `e` may contain an invalid package target nested deeply
in the returned errors. We should probably add a `.code()` to all errors
to make matching easier or make the errors flatter.
2024-07-11 16:32:52 -04:00
denobot
04ff5c731d
1.45.0 (#24512)
Bumped versions for 1.45.0

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-11 00:08:02 +02:00
David Sherret
a49d0bd10b
fix(check): CJS types importing dual ESM/CJS package should prefer CJS types (#24492)
Closes #16370
2024-07-10 14:46:25 -04:00
Marvin Hagemeister
26288cf2a9
fix(node/perf_hooks): stub eventLoopUtilization (#24501)
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-10 19:47:45 +02:00
Marvin Hagemeister
60668c1e93
fix(node/v8): stub serializer methods (#24502)
Stubbing a few of Node's `v8` serializer methods makes the `tap` test
runner at least start. Previously, it would fail to boot up as some
instances of `DefaultSerializer` are constructed eagerly 🎉

Before:
<img width="1041" alt="Screenshot 2024-07-10 at 16 41 30"
src="https://github.com/denoland/deno/assets/1062408/58f1157f-cef8-4176-9239-9d724ca0a677">


After:

<img width="830" alt="Screenshot 2024-07-10 at 16 39 35"
src="https://github.com/denoland/deno/assets/1062408/710ef673-8120-405a-b9d3-a5ca826b4829">


Fixes https://github.com/denoland/deno/issues/24409
2024-07-10 19:46:40 +02:00
Adam Gregory
82f9216610
fix: Add sys permission kinds for node compat (#24242)
Fixes #24241

* Support "statfs", "username", "getPriority" and "setPriority" kinds
for `--allow-sys`.
* Check individual permissions in `node:os.userInfo()` instead of a
single "userInfo" permission.
* Check for "uid" permission in `node:process.geteuid()` instead of
"geteuid".
* Add missing "homedir" to `SysPermissionDescriptor.kind` union

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-10 15:15:43 +02:00
Marvin Hagemeister
9a0d59d95d
fix(node/http): don't send destroyed requests (#24498)
Make sure that already destroyed requests are not actually sent.

This error was discovered in jsdom's test suite.
2024-07-10 12:01:08 +02:00
Marvin Hagemeister
2a86edf0af
fix(node/http): don't error if request destroyed before send (#24497)
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-10 10:05:41 +02:00
Nathan Whitaker
ce7dc2be92
feat(node): Support executing npm package lifecycle scripts (preinstall/install/postinstall) (#24487)
Adds support for running npm package lifecycle scripts, opted into via a
new `--allow-scripts` flag.

With this PR, when running `deno cache` (or `DENO_FUTURE=1 deno
install`) you can specify the `--allow-scripts=pkg1,pkg2` flag to run
lifecycle scripts attached to the given packages.

Note at the moment this only works when `nodeModulesDir` is true (using
the local resolver).

When a package with un-run lifecycle scripts is encountered, we emit a
warning suggesting things may not work and to try running lifecycle
scripts. Additionally, if a package script implicitly requires
`node-gyp` and it's not found on the system, we emit a warning.

Extra things in this PR:
- Extracted out bits of `task.rs` into a separate module for reuse
- Added a couple fields to `process.config` in order to support
`node-gyp` (it relies on a few variables being there)
- Drive by fix to downloading new npm packages to test registry

---

TODO:
- [x] validation for allow-scripts args (make sure it looks like an npm
package)
- [x] make allow-scripts matching smarter
- [ ] figure out what issues this closes

---
Review notes:
- This adds a bunch of deps to our test registry due to using
`node-gyp`, so it's pretty noisy
2024-07-10 03:06:08 +00:00
snek
c461f8fd2e
fix: do not return undefined for missing global properties (#24474)
accessing e.g. `Buffer` in `Mode::Deno` mode should throw, not return
undefined.

---------

Signed-off-by: snek <snek@deno.com>
2024-07-09 10:07:56 -07:00
David Sherret
839caf6faf
refactor: use concrete error types for node resolution (#24470)
This will help clean up some of the code in the CLI because we'll be
able to tell how the resolution failed (not part of this PR).
2024-07-09 12:15:03 -04:00
Marvin Hagemeister
07613a6bf2
fix(node/http): support all .writeHead() signatures (#24469)
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-09 17:46:10 +02:00
Marvin Hagemeister
b338b541ac
fix(node/assert): throws not checking error instance (#24466)
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-08 21:28:39 +02:00
Nathan Whitaker
d4d3a3c54f
fix(node): Implement fs.lchown (and process.getegid) (#24418)
Closes https://github.com/denoland/deno/issues/21260.
Part of https://github.com/denoland/deno/issues/18218.

Implements `node:fs.lchown`, and enables the node_compat test for it.
The test uses `process.getegid`, which we didn't have implemented, so I
went ahead and implemented that as well to get the test working.
2024-07-05 18:32:51 +00:00
Marvin Hagemeister
28d2ff7bdc
chore: remove unused class private properties (#24441)
Noticed that these private class properties are never used. Maybe a
leftover from an earlier implementation.
2024-07-05 16:27:06 +02:00
Luca Casonato
08e5606c34
fix(ext/node): rewrite digest handling (#24392)
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-05 10:10:22 +02:00
Divy Srivastava
b290fd01f3
fix(ext/node): http chunked writes hangs (#24428)
Fixes https://github.com/denoland/deno/issues/24239
2024-07-05 08:49:42 +05:30
David Sherret
d91215d418
fix: revert accidentally added parentPath on DirEntry (#24438)
Reverts the accidentally added `.parentPath` on dir entries in
https://github.com/denoland/deno/pull/24257/files

This should not have been added to the public api and is not documented.
2024-07-04 20:58:30 -04:00
Marvin Hagemeister
96b527b8df
fix(node/http): don't throw on .address() before .listen() (#24432)
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-04 18:28:48 +02:00
Satya Rohith
496ea5903b
fix(ext/node): don't wait for end() call to send http client request (#24390)
Closes https://github.com/denoland/deno/issues/24232
Closes https://github.com/denoland/deno/issues/24215
2024-07-03 19:00:39 +05:30
Nathan Whitaker
dadc606419
fix(ext/node): Add fs.lutimes / fs.lutimesSync (#23172)
Part of #18218


- Adds `fs.lutimes` and `fs.lutimesSync` to our node polyfills. To do
this I added methods to the `FileSystem` trait + ops to expose the
functionality to JS.
- Exports `fs._toUnixTimestamp`. Node exposes an internal util
`toUnixTimestamp` from the fs module to be used by unit tests (so we
need it for the unit test to pass unmodified). It's weird because it's
only supposed to be used internally but it's still publicly accessible
- Matches up error handling and timestamp handling for fs.futimes and
fs.utimes with node
- Enables the node_compat utimes test - this exercises futimes, lutimes,
and utimes.
2024-07-02 19:33:32 -07:00
Bartek Iwańczuk
8db420d552
chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24388)
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-07-02 02:09:47 +02:00
snek
a555cb4d1d
feat: upgrade deno_core (#24364)
- Symbol.asyncDispose no longer needs to be polyfilled
- assorted updates for cppgc api changes
2024-07-01 15:48:52 -07:00
Filip Skokan
740c6a0998
fix(ext/node): add Symbol.toStringTag to KeyObject instances (#24377)
As per https://github.com/nodejs/node/pull/46043, this adds
Symbol.toStringTag getter to KeyObject.
2024-07-02 00:36:22 +02:00
ud2
8d14a9db2f
fix(ext/node): make next tick queue resilient to Array.prototype tampering (#24361)
Closes #24358.
2024-06-27 21:45:46 +00:00
David Sherret
0da01c0ca6
refactor: move PackageJson to deno_config (#24348) 2024-06-26 21:24:10 +00:00
ud2
86e0292733
perf(ext/node): improve Buffer.from(buffer) (#24352)
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-26 17:11:56 -04:00
David Sherret
77ba0019e7
Revert "perf: improve Buffer.from(buf) by 29x" (#24351)
https://github.com/denoland/deno/pull/24341#discussion_r1655247367

Reverts denoland/deno#24341
2024-06-26 16:23:09 -04:00
Divy Srivastava
2549e5154c
perf: optimize Buffer.from("base64") for forgiving-base64 conforming input (#24346) 2024-06-26 06:24:58 -07:00
Divy Srivastava
6da87450ed
perf: improve Buffer.from(buf) by 29x (#24341) 2024-06-26 06:24:48 -07:00
Bartek Iwańczuk
09cc473f3b
fix(node): add missing readline/promises module (#24336)
Fixes https://github.com/jsr-io/jsr-npm/issues/91
2024-06-25 19:15:54 -04:00
snek
700cd200c1
feat: add module.parent (#24333)
This field is deprecated but still used by the ecosystem, so let's just
support it.
2024-06-25 11:17:35 -07:00
Satya Rohith
13aa1d70e9
fix(ext/node): ignore stream error during enqueue (#24243) 2024-06-25 17:02:40 +05:30
Luca Casonato
1e8a6b94b1
fix(ext/node): rewrite crypto.Hash (#24302)
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-24 11:47:12 +02:00
Asher Gomez
ff53506107
fix(ext/node): use primordials in ext/node/polyfills/_fs/_fs_dir.ts (#24319)
Towards #24236

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-06-24 06:22:55 +00:00
Asher Gomez
0833a1617c
fix(ext/node): use primordials in ext/node/polyfills/_fs/_fs_cp.js (#24320)
Towards #24236
2024-06-24 16:17:26 +10:00
Asher Gomez
dc4a88b7a6
fix(ext/node): use primordials in ext/node/polyfills/timers.ts (#24311)
Towards #24236
2024-06-24 15:50:02 +10:00
Asher Gomez
1c7ae83ca1
fix(ext/node): use primordials in ext/node/polyfills/testing.ts (#24310)
Towards #24236
2024-06-24 15:49:32 +10:00
Luca Casonato
973d186e8f
chore: use sha1 crate, not sha-1 (#24306) 2024-06-23 16:39:14 +02:00
Divy Srivastava
416df1e895
fix(ext/node): add ServerResponse#appendHeader (#24216) 2024-06-21 19:21:59 +05:30
Divy Srivastava
fc197a7ac0
Revert #[cppgc] &mut T usage (#24304) 2024-06-21 16:12:44 +05:30
Luca Casonato
e6756c3e66
fix(ext/node): don't panic on invalid utf-8 in pem (#24303) 2024-06-21 10:25:07 +00:00
Divy Srivastava
5683ca4070
chore(ext/node): cleanup zlib state ops (#24300) 2024-06-21 13:11:52 +05:30
Divy Srivastava
496428b82e
chore(ext/node): cleanup net blocklist ops (#24299) 2024-06-21 06:10:01 +00:00
Asher Gomez
9168078669
fix(ext/node): use primordials in ext/node/polyfills/string_decoder.ts (#24296) 2024-06-21 15:52:20 +10:00
Divy Srivastava
b4939f3379
fix: upgrade deno_core to 0.291.0 (#24297) 2024-06-21 10:49:39 +05:30
ud2
88e3f465d3
refactor(ext): remove use of brotli::ffi (#24214) 2024-06-20 20:44:24 +05:30
Asher Gomez
6ab143335a
fix(ext/node): use primordials in ext/node/polyfills/_brotli.js (#24235)
Towards #24236
2024-06-20 17:44:23 +10:00
Asher Gomez
510db0a86e
fix(ext/node): use primordials in ext/node/polyfills/_process/ (#24282) 2024-06-20 17:26:34 +10:00