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

218 commits

Author SHA1 Message Date
Yoshiya Hinosawa
dda6328745
fix(ext/node): stub process.cpuUsage() (#25462)
closes #23401
2024-09-05 21:21:29 +09:00
Luca Casonato
49e3ee010c
feat(ext/node): add abort helpers, process & streams fix (#25262)
This commit adds:

- `addAbortListener` in `node:events`
- `aborted` in `node:util`
- `execPath` and `execvArgs` named export from `node:process`
- `getDefaultHighWaterMark` from `node:stream`

The `execPath` is very hacky - because module namespaces can not have
real getters, `execPath` is an object with a `toString()` method that on
call returns the actual `execPath`, and replaces the `execPath` binding
with the string. This is done so that we don't require the `execPath`
permission on startup.
2024-09-05 09:22:52 +02:00
Yoshiya Hinosawa
e799c2857c
fix(ext/http): do not set localhost to hostname unnecessarily (#24777)
This commit changes when to cause the hostname substition of `0.0.0.0` ->
`localhost`.

Currently we substitute `localhost` to the hostname on windows before
calling `options.onListen`, which prevents the users to do more advanced
thing using hostname string like
https://github.com/denoland/std/issues/5558. This PR changes it not to
substitute it when the user provide `onListen` callback.

closes #24776
unblocks https://github.com/denoland/std/issues/5558
2024-09-05 14:13:06 +09:00
Yoshiya Hinosawa
186f7484da
fix(ext/node): close upgraded socket when the underlying http connection is closed (#25387)
This change fixes the handling of upgraded socket from `node:http` module.

In `op_node_http_fetch_response_upgrade`, we create DuplexStream paired
with `hyper::upgrade::Upgraded`. When the connection is closed from the
server, the read result from `Upgraded` becomes 0. However because we
don't close the paired DuplexStream at that point, the Socket object in
JS side keeps alive even after the server closed. That caused the issue
#20179

This change fixes it by closing the paired DuplexStream when the
`Upgraded` stream returns 0 read result.

closes #20179
2024-09-05 13:30:18 +09:00
David Sherret
4a5642779e
fix: upgrade deno_ast 0.42 (#25313) 2024-08-30 17:12:13 -04:00
Caleb Lloyd
4639ae655e
fix(ext/node): session close during stream setup (#25170)
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
2024-08-30 23:16:17 +05:30
Yoshiya Hinosawa
d71eebba0d
test(ext/node): check hostname option has precedence over host option (#25292) 2024-08-30 13:25:33 +09:00
snek
f7556d8962
fix: reland async context (#25140)
This reverts commit 71ca61e189.

Now uses a shared implementation from deno_core.
2024-08-29 02:25:38 +00:00
Bartek Iwańczuk
52fb6582e7
test: run node_unit_tests with DENO_FUTURE=1 (#25285)
This is blocking https://github.com/denoland/deno/pull/25213.

Turns out a bunch of FS APIs are completely broken because they
use RIDs (resource IDs) instead of FDs (file descriptors).
2024-08-29 00:09:06 +00:00
Divy Srivastava
0e50bb1d4a
fix(ext/node): import RSA JWK keys (#25267)
Fixes https://github.com/denoland/deno/issues/24129
2024-08-28 20:56:11 +05:30
Divy Srivastava
b9c144df6f
fix(ext/node): export JWK public key (#25239)
Fixes https://github.com/denoland/deno/issues/18928

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-08-28 15:03:02 +00:00
Divy Srivastava
553bd7dec3
fix(ext/node): import EC JWK keys (#25266) 2024-08-28 19:54:49 +05:30
Divy Srivastava
3394c4df75
fix(ext/node): update aead-gcm-stream to 0.3 (#25261)
Fixes https://github.com/denoland/deno/issues/25260
Fixes https://github.com/denoland/deno/issues/25254
Fixes https://github.com/denoland/deno/issues/23693

Verified that `web-push` GCM decryption works in the browser. See
`aead-gcm-stream` changes
[here](a9ffd0c07c)
2024-08-28 18:34:18 +05:30
Nathan Whitaker
511d13abaf
fix(ext/node): emit online event after worker thread is initialized (#25243)
Fixes #23281. Part of #20613.

We were emitting the `online` event in the constructor, so the caller
could never receive it (since there was no time for them to add a
listener). Instead, emit the event where it's intended – after the
worker is initialized.

---

After this parcel no longer freezes, but still will fail due to other
bugs (which will be fixed in other PRs)
2024-08-28 03:05:32 +00:00
Luca Casonato
e53678fd58
Revert "feat(fetch): accept async iterables for body" (#25207)
Unfortunately this caused a regression:
https://github.com/denoland/deno/issues/25203.

Need to do some more upstream spec work to fix this before this can be
re-landed.

Reverts denoland/deno#24623
2024-08-26 12:24:27 +02:00
Marvin Hagemeister
1dad29aa04
fix(node/cluster): improve stubs to make log4js work (#25146)
- Add missing exports to `node:cluster`
- Fix default export not being an instance of `EventEmitter`
- Fix aliasing of properties
- Fix `disconnected` -> `disconnect` export naming

This makes `log4js` work in Deno. `karma` starts too, but somehow the
server isn't responding. That looks like a different issue.

Fixes https://github.com/denoland/deno/issues/24858
2024-08-26 11:19:58 +02:00
Divy Srivastava
d9a7b30d1f
fix(ext/node): import JWK octet key pairs (#25180)
Ref https://github.com/denoland/deno/issues/24129

`kty: "okp"` is defined in
[rfc8037](https://www.rfc-editor.org/rfc/rfc8037.html)
2024-08-23 22:06:28 +05:30
Divy Srivastava
2531204a34
fix(ext/node): register node:wasi built-in (#25134)
Fixes https://github.com/denoland/deno/issues/23531
2024-08-22 09:03:52 +05:30
Satya Rohith
e920835417
fix(ext/node): pass content-disposition header as string instead of bytes (#25128)
Closes https://github.com/denoland/deno/issues/25117
2024-08-21 10:13:17 +00:00
David Sherret
a7c002ae63
chore: enable no-console dlint rule (#25113) 2024-08-20 15:14:37 -04:00
Marvin Hagemeister
48701c19f8
fix(node/tty): fix tty.WriteStream.hasColor with different args (#25094)
The check in `tty.WriteStream.prototype.hasColors()` was incorrect
leading to the
[`yoctocolors`](https://github.com/sindresorhus/yoctocolors) package not
printing any colors.

Fixes https://github.com/denoland/deno/issues/24407
2024-08-19 17:13:09 +02:00
Marvin Hagemeister
558d2a098b
fix(node/http): wrong req.url value (#25081)
This PR addresses a regression introduced in
https://github.com/denoland/deno/pull/25021 that would cause the
`req.url` parameter in Node's http server to always be a single
character instead of the expected value. The regression was caused by
effectively calling `.indexOf()` on an empty string and thus passing the
wrong index for slicing.

```js
"".indexOf("/") // -> -1
request.url.slice(-1) // effectively only giving us the last character
```

Fixes https://github.com/denoland/deno/issues/25080
2024-08-18 15:37:39 +00:00
Nathan Whitaker
ff4226a3cd
fix(node/fs): Use correct offset and length in node:fs.read and write (#25049)
My fix in #25030 was buggy, I forgot to pass the `byteOffset` and
`byteLength`. Whoops.

I also discovered that fs.read was not respecting the `offset` argument,
and we were constructing a new `Buffer` for the callback instead of just
passing the original one (which is what node does, and the @types/node
definitions also indicate the callback should get the same type).
Fixes #25028.
2024-08-16 09:48:57 -07:00
Sean McArthur
875ee618d3
feat(ext/node): support http2session.socket (#24786)
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-08-14 21:59:22 +00:00
Nathan Whitaker
1f2d48cd97
fix(node/fs): node:fs.read and write should accept typed arrays other than Uint8Array (#25030)
Part of #25028.

Our underlying read/write operations in `io` assume the buffer is a
Uint8Array, but we were passing in other typed arrays (in the case above
it was `Int8Array`).
2024-08-14 09:42:31 -07:00
Marvin Hagemeister
c765d9ad2f
fix(node/inspector): Session constructor should not throw (#25041)
There is no constructor code when creating an inspector `Session`
instance in Node. Also get rid of some symbols which should've been
private properties. This PR doesn't yet add any new implementations
though as these are mostly cosmetic changes.
2024-08-14 13:34:24 +00:00
Marvin Hagemeister
533d31bc4e
fix: node:inspector not being registered (#25007)
For some reason we didn't register the `node:inspector` module, which
lead to a panic when trying to import it. This PR registers it.

Related: https://github.com/denoland/deno/issues/25004
2024-08-14 12:33:42 +00:00
Kenta Moriuchi
76f4f202e7
chore: update the copyright of c, mjs, and jsx (#25005) 2024-08-12 12:41:32 -04:00
Luca Casonato
56e8ed5eb1
fix(ext/node): don't concat set-cookie in ServerResponse.appendHeader (#25000)
Follow-on to
https://github.com/denoland/deno/pull/24216/files#r1642188672
2024-08-12 12:01:37 +02:00
Divy Srivastava
d6f662ac82
fix(ext/node): support ieee-p1363 ECDSA signatures and pss salt len (#24981)
Fixes https://github.com/denoland/deno/issues/22919
2024-08-11 14:59:53 +05:30
Divy Srivastava
feba133711
fix(ext/node): createBrotliCompress params (#24984)
Fixes https://github.com/denoland/deno/issues/24416
2024-08-11 14:26:30 +05:30
Marvin Hagemeister
f474c4f4ff
fix: stub node:module.register() (#24965)
This is commonly used to register loading non standard file types. But
some libs also register TS loaders which Deno supports natively, like
the npm `payload` package. This PR unblocks those.

Fixes https://github.com/denoland/deno/issues/24902
2024-08-09 14:25:33 +02:00
Marvin Hagemeister
f50d38869d
fix(node/util): add missing debug alias of debuglog (#24944)
Add the missing `node:util.debug` export which is an alias of
`node:util.debuglog`, see
https://nodejs.org/api/util.html#utildebugsection
2024-08-08 13:52:14 +02:00
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
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
Leo Kettmeir
ba40347a35
feat(fetch): accept async iterables for body (#24623)
Implements https://github.com/whatwg/webidl/pull/1397
Fixes #21454 
Closes #24849
2024-08-06 00:13:02 -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
Luca Casonato
f1fc708d81
fix(ext/crypto): respect offsets when writing into ab views in randomFillSync (#24816) 2024-08-01 09:38:46 +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
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
Yoshiya Hinosawa
99e811f5eb
test(ext/node): reduce http_test flakiness (#24742) 2024-07-27 22:47:47 +09:00
Asher Gomez
5f44148e83
chore: update to std@2024.07.19 (#24715) 2024-07-25 15:30:28 +10: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
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
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
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
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
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
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
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
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
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
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
Divy Srivastava
416df1e895
fix(ext/node): add ServerResponse#appendHeader (#24216) 2024-06-21 19:21:59 +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
0b65d027a1
fix(ext/node): use cppgc for node:zlib (#24267) 2024-06-20 10:31:53 +05:30
Divy Srivastava
209b286813
fix(ext/node): Add Dirent.path and Dirent.parentPath (#24257) 2024-06-19 12:51:01 +05:30
Divy Srivastava
10ac3bb091
fix(ext/node): make process.versions own property (#24240) 2024-06-18 16:33:03 +05:30
Satya Rohith
8c4b33db0d
feat(ext/node): add BlockList & SocketAddress classes (#24229)
Closes https://github.com/denoland/deno/issues/24059
2024-06-18 10:46:13 +00:00
Asher Gomez
6819c3d7f6
fix(ext/node): use Deno.FsFile.statSync() (#24234) 2024-06-17 22:40:05 +00:00
Divy Srivastava
e19ee6eecc
fix(ext/node): server.close() does graceful shutdown (#24184) 2024-06-14 06:38:50 +05:30
Divy Srivastava
1d290ccc2a
fix(ext/node): fix vm memory usage and context initialization (#23976)
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-12 22:32:54 +05:30
Luca Casonato
3d41b486da
fix(ext/node): ServerResponse header array handling (#24149)
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-11 13:39:44 +03:00
Bartek Iwańczuk
eb218c0f33
chore: upgrade dlint to 0.60.0 (#24041)
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-05 01:09:29 +02:00
Kenta Moriuchi
eda43c46de
fix: validate integer values in Deno.exitCode setter (#24068) 2024-06-02 21:29:01 -04:00
Luke Edwards
13723f267e
feat: Add Deno.exitCode API (#23609)
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-29 23:16:27 +00:00
Satya Rohith
4f9b23b366
fix(ext/node): don't encode buffer data as utf8 in http2 (#24016) 2024-05-29 11:34:34 +05:30
Marvin Hagemeister
8c9d1ba1d7
fix(ext/node/fs): position argument not applied (#24009)
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-28 14:30:31 +02:00
Marvin Hagemeister
a0ddf73058
fix(ext/node): add throwIfNoEntry option in fs.lstatSync (#24006)
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-28 12:24:54 +02:00
Marvin Hagemeister
8806eac634
fix(node): set default http server response code 200 (#23977)
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-26 09:32:46 +02:00
Divy Srivastava
aeafb7b39e
fix(ext/node): add stubs for perf_hooks.PerformaceObserver (#23958)
Fixes https://github.com/denoland/deno/issues/23943
2024-05-23 04:59:20 -07:00
Asher Gomez
8a636d0600
feat(ext/fetch): Request.bytes() and Response.bytes() (#23823)
Closes #23790
2024-05-23 00:27:58 +00:00
Marvin Hagemeister
eb97f110db
fix(node): stub findSourceMap for ava (#23899)
This stubs `findSourceMap` in `node:module` by always returning
`undefined` as if it never found a source map. This unblocks the `ava`
test runner.

Fixes https://github.com/denoland/deno/issues/18666
2024-05-20 16:42:42 +02:00
Marvin Hagemeister
fb3f82b9ea
fix(node): track SIG* listeners in process.listeners (#23890)
Some npm libraries like `signal-exit` rely on the length of the listener
array returned by `process.listeners("SIGNT")` to be correct to
function. We weren't tracking `SIG*` events there, which broke those npm
libraries.

Fixes https://github.com/denoland/deno/issues/22892
2024-05-20 15:24:13 +02:00
Marvin Hagemeister
d7709daaa0
fix(node): patch MessagePort in worker_thread message (#23871)
Our `MessagePort` to Node's `MessagePort` conversion logic was missing
the case where a `MessagePort` is sent _inside_ the message. This broke
`tinypool` which is used by `vitest` as it relies on some node specific
methods on `MessagePort`.

Fixes https://github.com/denoland/deno/issues/23854 , Fixes
https://github.com/denoland/deno/pull/23871
2024-05-20 15:01:40 +02:00
Bedis Nbiba
927cbb5ecd
fix: handle signal 0 in process.kill (#23473)
the last commit had a regression, where it removed this branch, I
haven't tested the code but I think it should work

---------

Signed-off-by: Bedis Nbiba <bedisnbiba@gmail.com>
2024-05-19 14:52:03 -04:00
Marvin Hagemeister
75efc74931
fix(node): instantiating process class without new (#23865)
Popular test runners like Jest instantiate a new `Process` object
themselves and expect the class constructor to be callable without the
`new` keyword. This PR refactors our `Process` class implementation from
a proper ES2015 class to an ES5-style class which can be invoked both
with and without the `new` keyword like in Node.

Fixes https://github.com/denoland/deno/issues/23863
2024-05-17 16:24:07 +02:00
Divy Srivastava
bba553bea5
fix(ext/node): homedir() getpwuid/SHGetKnownFolderPath fallback (#23841)
**Unix**: Returns the value of the HOME environment variable if it is
set even if it is an empty string. Otherwise, it tries to determine the
home directory by invoking the
[getpwuid_r](https://linux.die.net/man/3/getpwuid_r) function with the
UID of the current user.

**Windows**: Returns the value of the USERPROFILE environment variable
if it is set and it is not an empty string. Otherwise, it tries to
determine the home directory by invoking the
[SHGetKnownFolderPath](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath)
function with
[FOLDERID_Profile](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid).

Fixes https://github.com/denoland/deno/issues/23824
2024-05-16 10:52:40 +05:30
Divy Srivastava
a31b81394b
fix(ext/node): export geteuid from node:process (#23840)
Fixes https://github.com/denoland/deno/issues/23827
2024-05-16 10:32:11 +05:30
Marvin Hagemeister
e02d0faedc
fix(node): wrong worker_threads.terminate() return value (#23803)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/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.
-->

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

---------

Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-15 17:08:25 +02:00
David Sherret
e661591e7c
chore: fix flaky '[node/http] send request with non-chunked body' test (#23818)
https://github.com/denoland/deno/actions/runs/9086887959/job/24973565321
2024-05-15 08:37:46 -04:00
Marvin Hagemeister
e389917535
fix(node): stub AsyncResource.emitDestroy() (#23802)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/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.
-->

Fixes https://github.com/denoland/deno/issues/23397
2024-05-15 00:42:43 +02:00
Bartek Iwańczuk
03a76f33ad
fix(ext/node): process.uptime works without this (#23786)
Fixes https://github.com/denoland/deno/issues/23761

Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-05-12 23:38:22 +00:00
Satya Rohith
56ba7f3c23
fix(ext/node): support delete process.env.var (#23647)
Closes https://github.com/denoland/deno/issues/23641
2024-05-02 06:40:22 +00:00
Satya Rohith
0156f82e73
fix(ext/node): support multiple message listeners on MessagePort (#23600)
Closes https://github.com/denoland/deno/issues/23561
2024-04-30 16:59:39 +05:30
Divy Srivastava
b02ffec37c
fix(ext/node): exporting rsa public keys (#23596)
Initial support for exporting rsa public KeyObject.

Current assumption is that RSA keys are stored in pkcs1 der format in
key storage.

Ref https://github.com/denoland/deno/issues/23471 
Ref https://github.com/denoland/deno/issues/18928
Ref https://github.com/denoland/deno/issues/21124
2024-04-29 19:16:38 +05:30
Bartek Iwańczuk
b424959d3e
fix(ext/node): worker_threads copies env object (#23536)
Most common argument to `env` option for `worker_threads.Worker` will be
`process.env`.

In Deno `process.env` is a `Proxy` which can't be cloned using
structured clone algorithm.

So to be safe, I'm creating a copy of actual object before it's sent to
the worker thread.

Ref #23522
2024-04-24 16:17:28 +00:00
Bartek Iwańczuk
14ae4f897f
fix(ext/node): define http.maxHeaderSize (#23479)
Closes https://github.com/denoland/deno/issues/23432
2024-04-21 07:31:23 +05:30