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

966 commits

Author SHA1 Message Date
Yoshiya Hinosawa
d59599fc18
fix(ext/node): fix dns.lookup result ordering (#26264)
partially unblocks #25470

This PR aligns the resolution of `localhost` hostname to Node.js
behavior.

In Node.js `dns.lookup("localhost", (_, addr) => console.log(addr))`
prints ipv6 address `::1`, but it prints ipv4 address `127.0.0.1` in
Deno. That difference causes some errors in the work of enabling
`createConnection` option in `http.request` (#25470). This PR fixes the
issue by aligning `dns.lookup` behavior to Node.js.

This PR also changes the following behaviors (resolving TODOs):
- `http.createServer` now listens on ipv6 address `[::]` by default on
linux/mac
- `net.createServer` now listens on ipv6 address `[::]` by default on
linux/mac

These changes are also alignments to Node.js behaviors.
2024-10-16 20:58:44 +09:00
Divy Srivastava
21fa953f32
fix(ext/node): timingSafeEqual account for AB byteOffset (#26292)
Fixes https://github.com/denoland/deno/issues/26276
2024-10-16 14:27:28 +05:30
Kenta Moriuchi
7211028f1e
fix(ext/node): use primordials in ext/node/polyfills/internal/buffer.mjs (#24993)
Towards #24236
2024-10-15 20:32:27 +02:00
Toby Ealden
c5a7f98d82
fix(ext/node): handle http2 server ending stream (#26235)
Closes #24845
2024-10-15 23:35:10 +05:30
Divy Srivastava
c7153838ec
fix(ext/node): implement TCP.setNoDelay (#26263)
Fixes https://github.com/denoland/deno/issues/26177

The significant delay was caused by Nagel's algorithm + delayed ACKs in
Linux kernels. Here's the [kernel
patch](https://lwn.net/Articles/502585/) which added 40ms
`tcp_default_delack_min`

```
$ deno run -A pg-bench.mjs # main
Tue Oct 15 2024 12:27:22 GMT+0530 (India Standard Time): 42ms

$ target/release/deno run -A pg-bench.mjs # this patch
Tue Oct 15 2024 12:28:02 GMT+0530 (India Standard Time): 1ms
```

```js
import { Buffer } from "node:buffer";

import pg from 'pg'
const { Client } = pg
const client = new Client({
    connectionString: 'postgresql://postgres:postgres@127.0.0.1:5432/postgres'
})
await client.connect()

async function fetch() {
    const startPerf = performance.now();
    const res = await client.query(`select
        $1::int as int,
        $2 as string,
        $3::timestamp with time zone as timestamp,
        $4 as null,
        $5::bool as boolean,
        $6::bytea as bytea,
        $7::jsonb as json
      `, [
        1337,
        'wat',
        new Date().toISOString(),
        null,
        false,
        Buffer.from('awesome'),
        JSON.stringify([{ some: 'json' }, { array: 'object' }])
    ])
    console.log(`${new Date()}: ${Math.round(performance.now() - startPerf)}ms`)
}

for(;;) await fetch();
```
2024-10-15 14:47:12 +05:30
Divy Srivastava
dfbf03eee7
perf: use fast calls for microtask ops (#26236)
Updates deno_core to 0.312.0
2024-10-14 12:31:51 +00:00
Divy Srivastava
bbad7c5922
fix(ext/node): compute pem length (upper bound) for key exports (#26231)
Fixes https://github.com/denoland/deno/issues/26188
2024-10-14 14:24:26 +05:30
Divy Srivastava
68b388a93a
fix(ext/node): allow writing to tty columns (#26201)
Behave similar to Node.js where modifying `stdout.columns` doesn't
really resize the terminal. Ref
https://github.com/nodejs/node/issues/17529

Fixes https://github.com/denoland/deno/issues/26196
2024-10-14 14:00:02 +05:30
Nathan Whitaker
4f89225f76
fix(node/util): export styleText from node:util (#26194)
Fixes #26184.

It was added but not publicly exported.
2024-10-12 19:36:23 +00:00
Marvin Hagemeister
9117a9a43c
fix(node): make process.stdout.isTTY writable (#26130)
Fixes https://github.com/denoland/deno/issues/26123
2024-10-11 19:14:10 +02:00
denobot
a62c7e036a
2.0.0 (#26063)
Bumped versions for 2.0.0

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-08 07:37:28 -07:00
Satya Rohith
ff4e682ff9
fix(ext/node): internal buffer length in readSync (#26064)
Closes https://github.com/denoland/deno/issues/26054
2024-10-08 10:41:32 +00:00
David Sherret
2de4faa483
refactor: improve node permission checks (#26028)
Does less work when requesting permissions with `-A`
2024-10-04 20:55:41 +01:00
Nathan Whitaker
dd8cbf5e29
fix(node): fix worker_threads issues blocking Angular support (#26024)
Fixes #22995. Fixes #23000.

There were a handful of bugs here causing the hang (each with a
corresponding minimized test):

- We were canceling recv futures when `receiveMessageOnPort` was called,
but this caused the "receive loop" in the message port to exit. This was
due to the fact that `CancelHandle`s are never reset (i.e., once you
`cancel` a `CancelHandle`, it remains cancelled). That meant that after
`receieveMessageOnPort` was called, the subsequent calls to
`op_message_port_recv_message` would throw `Interrupted` exceptions, and
we would exit the loop.

The cancellation, however, isn't actually necessary.
`op_message_port_recv_message` only borrows the underlying port for long
enough to poll the receiver, so the borrow there could never overlap
with `op_message_port_recv_message_sync`.

- Calling `MessagePort.unref()` caused the "receive loop" in the message
port to exit. This was because we were setting
`messageEventListenerCount` to 0 on unref. Not only does that break the
counter when multiple `MessagePort`s are present in the same thread, but
we also exited the "receive loop" whenever the listener count was 0. I
assume this was to prevent the recv promise from keeping the event loop
open.

Instead of this, I chose to just unref the recv promise as needed to
control the event loop.

- The last bug causing the hang (which was a doozy to debug) ended up
being an unfortunate interaction between how we implement our
messageport "receive loop" and a pattern found in `npm:piscina` (which
angular uses). The gist of it is that piscina uses an atomic wait loop
along with `receiveMessageOnPort` in its worker threads, and as the
worker is getting started, the following incredibly convoluted series of
events occurs:
   1. Parent sends a MessagePort `p` to worker
   2. Parent sends a message `m` to the port `p`
3. Parent notifies the worker with `Atomics.notify` that a new message
is available
   4. Worker receives message, adds "message" listener to port `p`
   5. Adding the listener triggers `MessagePort.start()` on `p`
6. Receive loop in MessagePort.start receives the message `m`, but then
hits an await point and yields (before dispatching the "message" event)
7. Worker continues execution, starts the atomic wait loop, and
immediately receives the existing notification from the parent that a
message is available
8. Worker attempts to receive the new message `m` with
`receiveMessageOnPort`, but this returns `undefined` because the receive
loop already took the message in 6
9. Atomic wait loop continues to next iteration, waiting for the next
message with `Atomic.wait`
10. `Atomic.wait` blocks the worker thread, which prevents the receive
loop from continuing and dispatching the "message" event for the
received message
11. The parent waits for the worker to respond to the first message, and
waits
12. The thread can't make any more progress, and the whole process hangs

The fix I've chosen here (which I don't particularly love, but it works)
is to just delay the `MessagePort.start` call until the end of the event
loop turn, so that the atomic wait loop receives the message first. This
prevents the hang.

---

Those were the main issues causing the hang. There ended up being a few
other small bugs as well, namely `exit` being emitted multiple times,
and not patching up the message port when it's received by
`receiveMessageOnPort`.
2024-10-04 09:26:32 -07:00
denobot
55c2a88099
chore: release deno_* crates (#25987)
Testing once again if the crates are being properly released.

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-02 14:27:34 +00:00
denobot
2d3e0284d9
chore: release deno_* crates (#25976)
Test run before Deno 2.0 release to make sure that the publishing
process passes correctly.

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-02 14:44:04 +02:00
Satya Rohith
32c1278736
feat(ext/node): buffer.transcode() (#25972)
Closes https://github.com/denoland/deno/issues/25911
2024-10-02 08:23:14 +00:00
Divy Srivastava
620e6b43a6
fix(ext/node): remove unimplemented promiseHook stubs (#25979)
`temporalio` sdk [will try to
use](faa64225a7/packages/worker/src/workflow/vm-shared.ts (L199-L202))
promiseHook if it is found. This patch removes the unimplemented stubs.

```ts
    if (promiseHooks) {
      // Node >=16.14 only
      this.stopPromiseHook = promiseHooks.createHook({
        init: (promise: Promise<unknown>, parent: Promise<unknown>) => {
```

Fixes https://github.com/denoland/deno/issues/25977
2024-10-02 12:52:05 +05:30
David Sherret
fc739dc5eb
refactor: use deno_path_util (#25918) 2024-09-28 07:55:01 -04:00
Nathan Whitaker
fbddd5a2eb
fix(node): Pass NPM_PROCESS_STATE to subprocesses via temp file instead of env var (#25896)
Fixes https://github.com/denoland/deno/issues/25401. Fixes
https://github.com/denoland/deno/issues/25841. Fixes
https://github.com/denoland/deno/issues/25891.
2024-09-27 12:35:37 -07:00
Asher Gomez
88a4f8dd97
chore: update simd-json (#25897) 2024-09-27 14:57:27 +10:00
Divy Srivastava
121d9697a1
fix(ext/node): fix process.stdin.pause() (#25864)
Fixes https://github.com/denoland/deno/issues/25844
2024-09-26 08:47:29 +05:30
Divy Srivastava
7d7e541724
fix(ext/node): Fix vm sandbox object panic (#24985) 2024-09-24 15:47:13 +05:30
Divy Srivastava
bfdca5bc7a
feat(ext/crypto): import and export p521 keys (#25789)
Towards https://github.com/denoland/deno/issues/13449
2024-09-23 19:40:36 +05:30
Volker Schlecht
37cedefb4d
fix(ext/node): stub cpu_info() for OpenBSD (#25807)
Add an implementation of cpu_info() for OpenBSD, that returns a
correctly-sized array. Since Rust's libc bindings for OpenBSD do not
contain all symbols necessary for a full implementation and it is not
planned to add them, this solution at least avoids problems with code
that relies on cpu_info() purely for the size of the returned array to
derive the number of available CPUs.

This addresses https://github.com/denoland/deno/issues/25621
2024-09-23 09:08:16 +05:30
Nathan Whitaker
4b022103a1
chore: Revert child_process close ordering change (#25781)
From
https://github.com/denoland/deno/commit/18b89d948dcb849c4dc577478794c3d5fb23b59

May have caused the recent flakiness of
parallel/test-child-process-ipc-next-tick.js
2024-09-20 23:46:42 +00:00
snek
a01dce3a25
fix: cjs resolution cases (#25739)
Fixes cjs modules being loaded as esm.
2024-09-19 21:10:34 -07:00
Divy Srivastava
e97f00f6f6
fix(ext/node): support x509 certificates in createPublicKey (#25731)
Fixes https://github.com/denoland/deno/issues/25681
2024-09-19 19:12:23 +05:30
Yoshiya Hinosawa
f460188e58
fix(ext/node): don't throw error for unsupported signal binding on windows (#25699) 2024-09-19 12:22:01 +09:00
Luca Casonato
ab1e391e1d
feat(ext/node): add rootCertificates to node:tls (#25707)
Closes https://github.com/denoland/deno/issues/25604

Signed-off-by: Satya Rohith <me@satyarohith.com>
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-09-18 21:14:26 +02:00
David Sherret
3dd83fdbdb
Revert "feat(fmt): sort type-only named import/exports last" (#25705)
Reverts #25690

This was not an issue with the ts compiler anymore. Discussion here:
https://github.com/dprint/dprint-plugin-typescript/pull/664#issuecomment-2357000053
2024-09-18 13:54:52 +00:00
Divy Srivastava
063f427ddf
fix(ext/node): stub inspector/promises (#25635)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-09-17 22:57:19 +05:30
David Sherret
a14e9f55b4
feat(fmt): sort type-only named import/exports last (#25690)
Closes #22583
2024-09-17 18:26:23 +01:00
David Sherret
62e952559f
refactor(permissions): split up Descriptor into Allow, Deny, and Query (#25508)
This makes the permission system more versatile.
2024-09-16 21:39:37 +01:00
Luca Casonato
81c9e0ba25
fix(ext/crypto): support md4 digest algorithm (#25656)
Fixes #25646
2024-09-16 11:04:40 +00:00
Divy Srivastava
db6fc12b9e
fix(ext/node): add vm.constants (#25630) 2024-09-15 08:15:28 +05:30
Divy Srivastava
4655172c0b
fix(ext/node): export process.allowedNodeEnvironmentFlags (#25629) 2024-09-15 08:15:19 +05:30
Divy Srivastava
ccd1ca8a8b
fix(ext/node): add stubs for node:trace_events (#25628) 2024-09-15 08:15:09 +05:30
snek
2c0bf6fd65
fix(ext/node): attach console stream properties (#25617)
`kBindStreamsLazy` should be called with `process` during init, but it
never was.
2024-09-13 17:28:35 -07:00
Jake Abed
d162733db2
fix(ext/node): use primordials in ext/node/polyfills/wasi.ts (#25608)
Toward #24236
2024-09-13 22:31:07 +05:30
Bartek Iwańczuk
71d5d47ca9
feat(ext/node): export 'promises' symbol from 'node:timers' (#25589) 2024-09-12 20:30:49 +00:00
Nathan Whitaker
18b89d948d
fix(ext/node): Implement detached option in child_process (#25218)
Fixes https://github.com/denoland/deno/issues/25193.
2024-09-12 19:24:58 +00:00
Yoshiya Hinosawa
3f15e30062
fix(ext/node): fix Decipheriv when autoPadding disabled (#25598)
This change fixes Decipheriv behavior when autoPadding disabled and enabled.

By this change, the example given in
https://github.com/denoland/deno/issues/20924#issuecomment-2345931295
works in the same way as Node.

closes #20924
2024-09-13 01:13:56 +09:00
Bartek Iwańczuk
46d5f38a0f
fix(ext/node): export request and response clases from http2 module (#25592)
Closes https://github.com/denoland/deno/issues/20612
Closes https://github.com/denoland/deno/issues/23326

This makes `qwik` work.
2024-09-12 02:03:57 +00:00
Bartek Iwańczuk
f794781ffb
feat(ext/node): expose ES modules for _ modules (#25588)
Exposes following modules:
- `"node:_http_agent"`
- `"node:_http_common"`
- `"node:_http_outgoing"`
- `"node:_http_server"`
- `"node:_stream_duplex"`
- `"node:_stream_passthrough"`
- `"node:_stream_readable"`
- `"node:_stream_transform"`
- `"node:_stream_writable"`
- `"node:_tls_common"`
- `"node:_tls_wrap"`
2024-09-12 00:52:08 +00:00
Bartek Iwańczuk
3a3837545c
feat(ext/node): export missing symbols from domain, puncode, repl, tls (#25585) 2024-09-12 02:25:46 +02:00
Bartek Iwańczuk
3f6605d123
feat(ext/node): export missing constants from 'zlib' module (#25584)
That puts us at 99.5% compatibility for this module.
2024-09-12 01:12:10 +02:00
Bartek Iwańczuk
05bd547238
feat(ext/node): export more symbols from streams and timers/promises (#25582) 2024-09-12 01:02:50 +02:00
Yoshiya Hinosawa
aae3a6bcb4
fix(ext/node): fix Cipheriv#update(string, undefined) (#25571) 2024-09-11 19:24:17 +09:00
Yoshiya Hinosawa
200145a09a
fix(ext/node): avoid showing UNKNOWN error from TCP handle (#25550) 2024-09-11 19:19:02 +09:00