Commit graph

1837 commits

Author SHA1 Message Date
Raashid Anwar
8ba828b41e
fix(http_client): Fix Deno.createHttpClient to accept poolIdleTimeout parameter (#21603)
Fixed the bug `Deno.createHttpClient` to accept `poolIdleTimeout` parameter.

Fixes https://github.com/denoland/deno/issues/21546
2023-12-31 12:45:12 +00:00
Jovi De Croock
4339a6c55d
fix(node/zlib): consistently return buffer (#21747)
This fixes point 3 of https://github.com/denoland/deno/issues/20516

This PR creates consistency between the sync and async versions of the
brotli compress where we will always return a buffer like Node.
2023-12-31 17:23:09 +05:30
Jovi De Croock
08fc8d50e3
fix(node/zlib): cast Dataview and Buffer to uint8 (#21746)
This fixes point 2 of #20516 

This adds a conversion from Dataview/Buffer by returning `obj.buffer`
which can be converted to a `UInt8Array`.

Question: Regarding point 4 of the mentioned issue would it be
appropriate to copy the toU8 helper to the `zlib.mjs` methods?
2023-12-31 17:20:37 +05:30
Divy Srivastava
3db9c8742d
fix(ext/node): add process.abort() (#21742) 2023-12-30 20:30:55 +05:30
Divy Srivastava
a7b21760fc
chore(runtime): internalize pipe fd for ext/node (#21570)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-12-30 05:32:30 +00:00
Bartek Iwańczuk
1dd1aba244
fix(node): support nested tests in "node:test" (#21717)
Closes https://github.com/denoland/deno/issues/21679
2023-12-29 16:18:08 +01:00
Bartek Iwańczuk
f85d65e066
chore: update deno_core to 0.240.0 (#21726) 2023-12-28 19:30:07 +00:00
Divy Srivastava
c08319262a
fix(node): Implement os.cpus() (#21697)
Fixes https://github.com/denoland/deno/issues/21666

Zero added dependency and tries to match the libuv implementation
2023-12-28 09:08:50 +05:30
Bartek Iwańczuk
c2414db1f6
refactor: simplify hyper, http, h2 deps (#21715)
Main change is that:
- "hyper" has been renamed to "hyper_v014" to signal that it's legacy
- "hyper1" has been renamed to "hyper" and should be the default
2023-12-27 11:59:57 -05:00
Bartek Iwańczuk
33acd437f5
refactor: finish test_util server cleanup, simplify dependencies (#21714)
Closes https://github.com/denoland/deno/issues/21578
2023-12-27 14:38:44 +01:00
Lino Le Van
d5f6e271ff
fix(ext/node): Implement aes-192-ecb and aes-256-ecb (#21710) 2023-12-27 17:24:52 +05:30
Matt Mastracci
0efe438f7c
perf: remove opAsync (#21690)
`opAsync` requires a lookup by name on each async call. This is a
mechanical translation of all opAsync calls to ensureFastOps.

The `opAsync` API on Deno.core will be removed at a later time.
2023-12-27 02:30:26 +01:00
Bartek Iwańczuk
e33c5eb704
refactor: fastwebsockets renames (#21707)
We now use only a single version of "fastwebsockets" crate, so we no
longer need to have an alias.
2023-12-26 21:53:28 +01:00
Bartek Iwańczuk
8fbac67395
refactor: change cli/ to use hyper 1.1 (#21705) 2023-12-26 14:32:21 +01:00
Bartek Iwańczuk
753777b4af
refactor: migrate ext/websocket to hyper 1.1 (#21699) 2023-12-26 11:20:49 +01:00
Divy Srivastava
60da9d493c
fix(ext/node): add ClientRequest#setNoDelay (#21694)
Fixes https://github.com/denoland/deno/issues/18316
2023-12-25 08:58:51 +05:30
Bartek Iwańczuk
e1bfb29868
refactor: use hyper 1.0 in grpc test server (#21584)
Ref https://github.com/denoland/deno/issues/21578
2023-12-24 14:14:29 +01:00
Matt Mastracci
92b2e28c64
chore: ensure that each op provided to ensureFastOps is only used once (#21689)
When we migrate to op-import-per-extension, we will want to ensure that
ops have one and only one place where they are imported. This tackles
the ops that are imported via `ensureFastOps`, but does not yet tackle
direct `ops` imports.

Landing ahead of https://github.com/denoland/deno_core/pull/393
2023-12-24 13:04:32 +00:00
Matt Mastracci
1297c9a8f3
chore(ext/node): use BufView natively in http2 (#21688)
Node HTTP/2 was using the default h2 `Bytes` datatype when we can be
making using of `BufView` like we do in `Deno.serve`.

`fetch` and `Deno.serverHttp` can't make use of `BufView` because they
are using `reqwest` which is stuck on hyper 0.x at this time.
2023-12-23 08:58:20 -07:00
Heyang Zhou
140e8becd0
feat(unstable): only allow http2 for kv remote backend (#21616) 2023-12-23 01:19:17 +08:00
Bartek Iwańczuk
f86456fc26
chore: update ext/http to hyper 1.0.1 and http 1.0 (#21588)
Closes https://github.com/denoland/deno/issues/21583.
2023-12-22 01:54:28 +01:00
Heyang Zhou
3fb4f3fe5a
fix(unstable): kv watch should stop when db is closed (#21665)
Fixes #21634.
2023-12-22 05:04:17 +08:00
Bartek Iwańczuk
760af934d9
chore: forward v1.39.1 commit to main (#21667) (#21671)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2023-12-21 18:43:52 +00:00
Divy Srivastava
26cf06ed9f
fix(node): child_process kill cancel pending IPC reads (#21647) 2023-12-20 07:55:09 +05:30
Divy Srivastava
5aa27c45f1
fix(node): add crypto.pseudoRandomBytes (#21649) 2023-12-20 07:54:55 +05:30
Divy Srivastava
55fac9f5ea
fix(node): child_process IPC on Windows (#21597)
This PR implements the child_process IPC pipe between parent and child.
The implementation uses Windows named pipes created by parent and passes
the inheritable file handle to the child.

I've also replace parts of the initial implementation which passed the
raw parent fd to JS with resource ids instead. This way no file handle
is exposed to the JS land (both parent and child).

`IpcJsonStreamResource` can stream upto 800MB/s of JSON data on Win 11
AMD Ryzen 7 16GB (without `memchr` vectorization)
2023-12-19 13:37:22 +01:00
Kenta Moriuchi
68241234fa
fix(console): inspect for {Set,Map}Iterator and Weak{Set,Map} (#21554) 2023-12-19 15:05:49 +09:00
Divy Srivastava
81a6504e67
refactor: setup child process pipe in Rust (#21579)
Avoid passing the fd into JS and back into Rust. Instead we setup the
child's end of the pipe directly using a special Rust op.
2023-12-15 11:50:05 +01:00
Divy Srivastava
28048e7c12
fix(net): remove unstable check for unix socket listen (#21592)
Fixes https://github.com/denoland/deno/issues/21587

It seems this was missed in https://github.com/denoland/deno/pull/21463.
cc @bartlomieju
2023-12-15 10:22:40 +01:00
Bartek Iwańczuk
c481ff7d81
refactor(ext/http): fork fly_accept_encodings crate (#21586)
Blocks update to Hyper 1.0. It's a really small library, no need to pull
it as a dependency.

Blocker for #21583
2023-12-14 18:43:33 +00:00
David Sherret
ac04787c30
fix(node): support resolving a package.json import to a builtin node module (#21576)
Closes https://github.com/denoland/deno/issues/21501
2023-12-14 15:09:05 +00:00
Divy Srivastava
f2c56dc3d8
chore(node): remove process.on("disconnect") not implemented warning (#21569) 2023-12-14 11:28:23 +01:00
Divy Srivastava
5ace65485f
fix(node): return false from vm.isContext (#21568)
https://github.com/denoland/deno/issues/20851#issuecomment-1779226106
for `jsdom`
2023-12-14 10:19:50 +00:00
denobot
04ba8df711
1.39.0 (#21560)
Bumped versions for 1.39.0

Please ensure:
- [x] Target branch is correct (`vX.XX` if a patch release, `main` if
minor)
- [x] Crate versions are bumped correctly
- [x] deno_std version is incremented in the code (see
`cli/deno_std.rs`)
- [x] Releases.md is updated correctly (think relevancy and remove
reverts)

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

cc @mmastrac

---------

Co-authored-by: mmastrac <mmastrac@users.noreply.github.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-12-13 13:24:13 -07:00
Divy Srivastava
38002ffdd7
fix(zlib): handle no flush flag in handle_.write (#21432)
Fixes https://github.com/denoland/deno/issues/21096
2023-12-13 09:58:56 -07:00
Heyang Zhou
10ab8c1ef1
feat(unstable): append commit versionstamp to key (#21556) 2023-12-14 00:58:20 +08:00
Divy Srivastava
461ef6bdd8
fix(websockets): server socket field initialization (#21433) 2023-12-13 14:21:34 +00:00
Divy Srivastava
5a91a065b8
fix: implement child_process IPC (#21490)
This PR implements the Node child_process IPC functionality in Deno on
Unix systems.

For `fd > 2` a duplex unix pipe is set up between the parent and child
processes. Currently implements data passing via the channel in the JSON
serialization format.
2023-12-13 11:14:16 +01:00
Igor Zinkovsky
86769b0d1c
feat(ext/kv) add backoffSchedule to enqueue (#21474)
Also reduces the time to run `kv_queue_undelivered_test.ts` test from
100 seconds down to 3 seconds.

closes #21437
2023-12-12 22:51:23 -08:00
Matt Mastracci
a4f45f7092
perf(ext/ffi): switch from middleware to tasks (#21239)
Deno-side changes for https://github.com/denoland/deno_core/pull/350

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-12-12 03:10:33 +00:00
Matt Mastracci
d13e45f2b3
perf(ext/napi): port NAPI to v8 tasks (#21406)
Part 2 of removing middleware.

This is somewhat awkward because `V8CrossThreadTaskSpawner` requires
tasks to be `Send`, but NAPI makes heavy use of `!Send` pointers. In
addition, Rust causes a closure to be `!Send` if you pull a `!Send`
value out of a struct.

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-12-11 10:52:55 -07:00
Ryan Dahl
98121de5be
fix: allow reserved word 'mod' in exports (#21537)
This problem occurred trying to load tensorflow.js
```
> import * as tf from 'npm:@tensorflow/tfjs';
Uncaught SyntaxError: Identifier 'mod' has already been declared at file:///Users/ry/Library/Caches/deno/npm/registry.npmjs.org/@tensorflow/tfjs/4.14.0/dist/tf.node.js:167:14
    at async <anonymous>:1:33
```
2023-12-11 17:23:50 +01:00
Divy Srivastava
02e138dca9
fix(ext/node): basic vm.runInNewContext implementation (#21527)
Simple implementation to support webpack (& Next.js):
8766092180/lib/javascript/JavascriptParser.js (L4329)
2023-12-11 07:08:45 +00:00
Divy Srivastava
0bee37a5e2
fix(ext/websocket): don't panic on bad resource id (#21431)
https://github.com/denoland/deno/issues/21379
2023-12-11 12:22:54 +05:30
Divy Srivastava
5e24e28318
fix(ext/node): ServerResponse getHeader() return undefined (#21525)
Matches Node's return type.

Next.js check for `if (header === undefined)`:

e02fe314dc/packages/next/src/server/base-http/node.ts (L93)
2023-12-11 11:11:59 +05:30
Divy Srivastava
e8fc7c20b7
fix(ext/node): stub ServerResponse#flushHeaders (#21526)
This commit adds a no-op flushHeaders method to the ServerResponse
object. It is a nop because the ServerResponse implementation is based
on top of the Deno server API instead of the Node `OutgoingMessage`
base.

Fixes #21509
2023-12-11 04:46:12 +00:00
Leo Kettmeir
393abed387
feat: bring back WebGPU (#20812)
Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-09 01:19:16 +01:00
Luca Casonato
e15c735ede
perf(ext/url): improve URLPattern perf (#21488)
This significantly optimizes URLPattern in the case where the same
URL is matched against many patterns (like in a router).

Also minor speedups to other use-cases.
2023-12-08 12:02:52 +01:00
Kenta Moriuchi
b24356d9b9
fix(ext/node): use primordials in ext/node/polyfills/_util (#21444) 2023-12-08 18:00:03 +09:00
Yoshiya Hinosawa
3a74fa60ca
fix(ext/node): allow null value for req.setHeader (#21391)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-08 17:43:19 +09:00
Max Goodhart
2235a1a359
fix(node/tls): fix NotValidForName for host set via socket / servername (#21441)
This PR is an attempt to fix
https://github.com/denoland/deno/issues/20293, in which node modules
connecting to databases fail due to TLS errors. I ran into this
attempting to use
[node-postgres](https://github.com/brianc/node-postgres) to connect to a
[Neon](https://neon.tech) database.

Investigating via `--inspect-brk` led me to notice that the hostname
eventually passed to `Deno.startTls` was null. The hostname is
determined by the following code:


f6b889b432/ext/node/polyfills/_tls_wrap.ts (L87-L89)

This logic doesn't appear to be correct. I couldn't find reference to
`servername` existing on the `secureContext` in either Node's or Deno's
docs. There's a lot of scope here, and it's my first time reading
through this code, so I could be missing something!

Node uses [the following
logic](2e458d9736/lib/_tls_wrap.js (L1679-L1682)
) to determine the hostname for certificate validation:
 
```
    const hostname = options.servername ||
                   options.host ||
                   (options.socket && options.socket._host) ||
                   'localhost';
```

This PR updates the `TLSSocket` polyfill to use behave similarly (though
I omitted the default to `localhost` at the end; I'm not sure if
including it is necessary or correct). With this change, `node-postgres`
connects to my TLS endpoint successfully (aside: Neon requires SNI,
which also works as expected).

---

I tried to update the tests in
https://github.com/denoland/deno/blob/main/cli/tests/unit_node/tls_test.ts
to exercise this change, but the test fails for me on `main` on Linux. I
investigated briefly and noticed that the test fixture
`cli/tests/testdata/tls/localhost.crt` doesn't appear to include the
`subjectAltName` specified in `domains.txt`. I believe the certificate
isn't matching `localhost`, but that's where I ended investigating.
2023-12-08 03:53:36 +00:00
ud2
3f96e5a29a
fix(ext/node): include non-enumerable keys in Reflect.ownKeys(globalThis) (#21485)
Closes #21484.
2023-12-07 21:34:44 +05:30
Bartek Iwańczuk
c1fc7b2cd5
refactor: pull 'core', 'internals', 'primordials' from ES module (#21462)
This commit refactors how we access "core", "internals" and
"primordials" objects coming from `deno_core`, in our internal JavaScript code.

Instead of capturing them from "globalThis.__bootstrap" namespace, we
import them from recently added "ext:core/mod.js" file.
2023-12-07 14:21:01 +01:00
Matt Mastracci
9314928990
chore: bump deno_core and update tests (#21467)
Landing changes required for
https://github.com/denoland/deno_core/pull/359

We needed to update 99_main.js and a whole load of tests.

API changes:

- setPromiseRejectCallback becomes setUnhandledPromiseRejectionHandler.
The function is now called from eventLoopTick.
- The promiseRejectMacrotaskCallback no longer exists, as this is
automatically handled in eventLoopTick.
- ops.op_dispatch_exception now takes a second parameter: in_promise.
The preferred way to call this op is now reportUnhandledException or
reportUnhandledPromiseRejection.
2023-12-06 17:02:52 -07:00
Bartek Iwańczuk
a931a47511
feat: stabilize Deno.HttpServer.shutdown and Unix socket support (#21463)
This commit stabilizes "Deno.HttpServer.shutdown" API as well as
Unix socket support in "Deno.serve" API.

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-12-06 23:43:01 +00:00
Jamie
8c0fb9003d
feat(ext/web): add ImageData Web API (#21183)
Fixes #19288

Adds the `ImageData` Web API. 

This would be beneficial to projects using `ImageData` as a convenient
transport layer for pixel data. This is common in Web Assembly projects
that manipulate images. Having this global available in Deno would
improve compatibility of existing JS libraries.

**References**
- [MDN ImageData Web
API](https://developer.mozilla.org/en-US/docs/Web/API/ImageData)
- [whatwg HTML Standard Canvas
Spec](https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation)
2023-12-06 14:20:28 +01:00
Yusuke Tanaka
dadd8b3d66
feat(ext/fetch): allow Deno.HttpClient to be declared with using (#21453)
This commit adds a method of `Symbol.dispose` to the object returned
from `Deno.createHttpClient`, so we can make use of [explicit resource
management](https://github.com/tc39/proposal-explicit-resource-management)
by declaring it with `using`.
2023-12-06 16:52:59 +09:00
Bartek Iwańczuk
bd7a6bb016
chore: forward v1.38.5 release commit to main (#21472)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
2023-12-06 00:53:16 +00:00
Raashid Anwar
cac17267fb
fix(ext/kv): throw error if already closed (#21459)
If KV is closed and tries to listen queue should throw an error

closes #20991
2023-12-05 10:16:47 -08:00
Luca Casonato
74e39a927c
feat(unstable): kv.watch() (#21147)
This commit adds support for a new `kv.watch()` method that allows
watching for changes to a key-value pair. This is useful for cases
where you want to be notified when a key-value pair changes, but
don't want to have to poll for changes.

---------

Co-authored-by: losfair <zhy20000919@hotmail.com>
2023-12-05 21:21:46 +08:00
David Sherret
a24d3e8763
perf(node/fs): faster existsSync when not exists (#21458) 2023-12-04 21:05:40 +00:00
Divy Srivastava
32438d25c3
fix(ext/node): sign with PEM private keys (#21287)
Add support for signing with a RSA PEM private key: `pkcs8` and `pkcs1`.

Fixes https://github.com/denoland/deno/issues/18972
Ref #21124 

Verified fix with `npm:sshpk`. Unverfied but fixes
`npm:google-auth-library`, `npm:web-push` & `oracle/oci-typescript-sdk`

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-12-03 09:58:13 +05:30
David Sherret
f29075ae4c
fix(node): setting process.exitCode should change exit code of process (#21429) 2023-12-02 16:03:37 +00:00
Asher Gomez
d2b5254c33
chore: update std to 0.208.0 (#21318)
Re-attempt at #21284. I was more thorough this time.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-12-02 03:20:06 +01:00
Matt Mastracci
e6e708e46c
refactor: use resourceForReadableStream for fetch (#20217)
Switch `ext/fetch` over to `resourceForReadableStream` to simplify and
unify implementation with `ext/serve`. This allows us to work in Rust
with resources only.

Two additional changes made to `resourceForReadableStream` were
required:

- Add an optional length to `resourceForReadableStream` which translates
to `size_hint`
 - Fix a bug where writing to a closed stream that was full would panic
2023-12-01 08:56:10 -07:00
Daniel Mizerski
687ae870d1
fix(ext/node): add stubbed process.report (#21373)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-12-01 15:36:11 +09:00
Bartek Iwańczuk
b69001bb49
chore: forward v1.38.4 release commit to main (#21400)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
2023-11-30 23:06:54 +01:00
Raashid Anwar
ab755a07d8
feat(cron): added the support for json type schedule to cron api (#21340)
Added the support for JSON type schedule to cron API; previously it was string only.
fixes #21122
2023-11-30 13:51:56 -08:00
Laurence Rowe
8050cbf39e
perf(ext/web): Avoid changing prototype by setting hostObjectBrand directly (#21358) 2023-11-30 14:06:16 -07:00
Jordan Harband
334c118c97
refactor (parseCssColor): use parseInt, avoid unnecessary coercion (#20856)
Upstream some changes from https://github.com/nodejs/node/pull/49205

Signed-off-by: Jordan Harband <ljharb@gmail.com>
2023-11-30 18:33:44 +00:00
Yoshiya Hinosawa
3591ba8578
fix(ext/node): fix os.freemem (#21347) 2023-11-30 22:06:01 +09:00
Yoshiya Hinosawa
e332fa4a83
fix(ext/node): add util.parseArgs (#21342) 2023-11-29 15:42:58 +09:00
Igor Zinkovsky
75ec650f08
chore(ext/kv): update denokv crates (#21357) 2023-11-28 21:04:07 -08:00
Leo Kettmeir
32c041c8d7
Reland "fix(ext/console): fix inspecting iterators error. (#20720)" (#21370) 2023-11-28 16:07:48 +01:00
Yoshiya Hinosawa
567d7ff923
fix(ext/node): fix Buffer.copy when sourceStart > source.length (#21345) 2023-11-28 22:28:07 +09:00
Yoshiya Hinosawa
4ed9278bf4
fix(ext/node): fix duplexify compatibility (#21346) 2023-11-28 12:14:57 +09:00
Matt Mastracci
4a2672bc29
chore: add retries to autobahn (#21365) 2023-11-28 01:44:48 +00:00
David Sherret
d4ef471744
fix(node): spawnSync's status was incorrect (#21359)
The exit code wasn't hooked up properly.
2023-11-27 19:54:01 -05:00
Matt Mastracci
8ce4ddc407
chore(ext/http): fix E0446 on some compiler versions (#21362)
Rust 1.74 may have made this code temporarily valid in [#113126 Replace
old private-in-public diagnostic with type privacy
lints](https://github.com/rust-lang/rust/pull/113126), so we didn't
catch it at build time.

It fails in 1.73 and +nightly, however.
2023-11-27 23:12:55 +00:00
Leo Kettmeir
6f02fa1abf
feat(streams): ReadableStream.read min option (#20849) 2023-11-24 23:24:41 +01:00
denobot
2941dd7da8
chore: forward v1.38.3 release commit to main (#21320) 2023-11-24 07:09:15 +01:00
Matt Mastracci
68a0877f8d
fix(ext/http): avoid lockup in graceful shutdown (#21253)
Follow-up to #20822. cc @lrowe 

The `httpServerExplicitResourceManagement` tests were randomly failing
on CI because of a race.

The `drain` waker was missing wakeup events if the listeners shut down
after the last HTTP response finished. If we lost the race (rare), the
server Rc would be dropped and we wouldn't poll it again.

This replaces the drain waker system with a signalling Rc that always
resolves when the refcount is about to become 1.

Fix verified by running serve tests in a loop:

```
for i in {0..100}; do cargo run --features=__http_tracing -- test
 -A --unstable '/Users/matt/Documents/github/deno/deno/cli/tests/unit/ser
ve_test.ts' --filter httpServerExplicitResourceManagement; done;
```
2023-11-23 16:39:17 +00:00
Yoshiya Hinosawa
bf42467e21
fix(ext/node): fix node:stream.Writable (#21297)
This change applies the same fix as
https://github.com/nodejs/node/pull/46818, and the original example
given in #20456 works as expected.

closes #20456
2023-11-23 09:57:05 +09:00
Asher Gomez
616354e76c
refactor: replace deferred() from std/async with Promise.withResolvers() (#21234)
Closes #21041

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-11-22 12:11:20 +01:00
Divy Srivastava
c97a97240b
fix(ext/node): handle closing process.stdin more than once (#21267)
Fixes https://github.com/denoland/deno/issues/21112

Aligns more towards what Node.js does. Closing stdin more than once is a
nop.
2023-11-20 18:57:18 +05:30
Kenta Moriuchi
498bdc1e2a
fix(ext/url): add deno_console dependency for bench (#21266)
Should fix the benchmarks.

Signed-off-by: Kenta Moriuchi <moriken@kimamass.com>
2023-11-20 14:01:30 +01:00
Kenta Moriuchi
c806fbdabe
fix(ext,runtime): add missing custom inspections (#21219) 2023-11-19 09:13:38 +01:00
Matt Mastracci
76df375c84
chore(ext/http): bump version for re-release (#21254)
Syncs the changes to main for a deno_http version bump we needed to do.
`deno_http` v1.20 was released from the v1.38 branch.
2023-11-18 15:13:17 -07:00
Matt Mastracci
679b7bb8fa
fix(ext/http): fix crash in dropped Deno.serve requests (#21252)
Fixes #21250

We were attempting to recycle dropped resource responses too early.
2023-11-18 13:16:53 -07:00
denobot
21e6a76519
chore: forward v1.38.2 release commit to main (#21236)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-11-17 17:57:25 +09:00
David Sherret
544923afdc
fix(doc): issue discovering re-exports of re-exports sometimes (#21223) 2023-11-16 17:34:56 -05:00
Igor Zinkovsky
b572abfcb3
feat(ext/cron) modify Deno.cron API to make handler arg last (#21225)
This PR changes the `Deno.cron` API:
* Marks the existing function as deprecated
* Introduces 2 new overloads, where the handler arg is always last:
```ts
Deno.cron(
  name: string,
  schedule: string,
  handler: () => Promise<void> | void,
)

Deno.cron(
  name: string,
  schedule: string,
  options?: { backoffSchedule?: number[]; signal?: AbortSignal },
  handler: () => Promise<void> | void,
)
```

This PR also fixes a bug, when other crons continue execution after one
of the crons was closed using `signal`.
2023-11-16 14:19:00 -08:00
Matt Mastracci
6b42cecc06
feat(ext/net): use rustls_tokio_stream (#21205)
Fixes #21121 and #19498

Migrates fully to rustls_tokio_stream. We no longer need to maintain our
own TlsStream implementation to properly support duplex.

This should fix a number of errors with TLS and websockets, HTTP and
"other" places where it's failing.
2023-11-15 16:12:46 -07:00
Bartek Iwańczuk
cf6673b23d
fix(ext/node): add APIs perf_hook.performance (#21192)
Required for Next.js.
2023-11-14 16:33:09 +05:30
Kenta Moriuchi
886652156e
fix(ext/web): webstorage has trap for symbol (#21090) 2023-11-14 07:01:15 +01:00
Bartek Iwańczuk
9b9ec44db7
Revert "fix(ext/console): fix inspecting iterators error. (#20720)" (#21191)
This reverts commit 0209f7b469.

Reverting because it causes failures on `main`:
https://github.com/denoland/deno/pull/20720#issuecomment-1809166755
2023-11-13 22:16:23 +00:00
Laurence Rowe
e5819777c3
refactor(ext/http): Use HttpRecord as response body to track until body completion (#20822)
Use HttpRecord as response body so requests can be tracked all the way
to response body completion.

This allows Request properties to be accessed while the response body is
streaming.

Graceful shutdown now awaits a future instead of async spinning waiting
for requests to finish.

On the minimal benchmark this refactor improves performance an
additional 2% over pooling alone for a net 3% increase over the previous
deno main branch.

Builds upon https://github.com/denoland/deno/pull/20809 and
https://github.com/denoland/deno/pull/20770.

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-11-13 19:17:31 +00:00
Chen Su
0209f7b469
fix(ext/console): fix inspecting iterators error. (#20720)
Fixes #19776 and #20676.
2023-11-13 20:13:20 +01:00
Laurence Rowe
25950baed3
perf(ext/http): Object pooling for HttpRecord and HeaderMap (#20809)
Reuse existing existing allocations for HttpRecord and response
HeaderMap where possible.

At request end used allocations are returned to the pool and the pool
and the pool sized to 1/8th the current number of inflight requests.

For http1 hyper will reuse the response HeaderMap for the following
request on the connection.

Builds upon https://github.com/denoland/deno/pull/20770

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-11-13 10:32:34 -07:00
Laurence Rowe
542314a0be
refactor(ext/http): refer to HttpRecord directly using v8::External (#20770)
Makes the JavaScript Request use a v8:External opaque pointer to
directly refer to the Rust HttpRecord.

The HttpRecord is now reference counted. To avoid leaks the strong count
is checked at request completion.

Performance seems unchanged on the minimal benchmark. 118614 req/s this
branch vs 118564 req/s on main, but variance between runs on my laptop
is pretty high.

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-11-13 07:04:49 -07:00
Divy Srivastava
1ef617e8f3
perf: lazy bootstrap options - first pass (#21164)
Move most runtime options to be lazily loaded. Constant options will be
covered in a different PR.

Towards https://github.com/denoland/deno/issues/21133
2023-11-13 04:52:59 +00:00
Kenta Moriuchi
39223f709b
feat(ext/web): add AbortSignal.any() (#21087)
Fixes #18944
2023-11-13 01:04:11 +01:00
Florian Schwalm
3a7abe6906
fix(ext/web): Prevent TextDecoderStream resource leak on stream cancellation (#21074)
This PR uses the new `cancel` method of `TransformStream` to properly
clean up the internal `TextDecoder` used in `TextDecoderStream` if the
stream is cancelled.

Fixes #13142

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-12 12:47:03 -07:00
Divy Srivastava
9f4a45561f
perf: snapshot runtime ops (#21127)
Closes https://github.com/denoland/deno/issues/21135

~1ms startup time improvement

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-11-11 17:01:48 +00:00
Matt Mastracci
56e76242f3
chore(ext/node): use libz-sys w/zlib-ng feature in node (#21158)
We only want one zlib dependency.

Zlib dependencies are reorganized so they use a hidden
`__vendored_zlib_ng` flag in cli that enables zlib-ng for both libz-sys
(used by ext/node) and flate2 (used by deno_web).
2023-11-11 07:20:12 -07:00
Jacob Hummer
b2e3389a6a
fix(node/http): export globalAgent (#21081)
Fixes #21080 
Fixes #18312

---------

Signed-off-by: Jacob Hummer <jcbhmr@outlook.com>
2023-11-11 10:13:30 +05:30
Divy Srivastava
df14835b83
fix(ext/node): implement process.geteuid (#21151)
Fixes #21097
2023-11-10 11:49:57 -07:00
Divy Srivastava
05704fbf78
chore: use pure rust secp256k1 crate (#21154)
Saves ~40s in fresh debug build
2023-11-10 22:59:01 +05:30
denobot
1ece7dfd90
chore: forward v1.38.1 release commit to main (#21144)
This is the release commit being forwarded back to main for 1.38.1

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: littledivy <littledivy@users.noreply.github.com>
2023-11-10 18:51:34 +05:30
Bartek Iwańczuk
612b7dfcc7
fix(node/child_process): properly normalize stdio for 'spawnSync' (#21103)
Closes https://github.com/denoland/deno/issues/20782
2023-11-10 05:59:39 +00:00
Matt Mastracci
9010b8df53
perf: remove knowledge of promise IDs from deno (#21132)
We can move all promise ID knowledge to deno_core, allowing us to better
experiment with promise implementation in deno_core.

`{un,}refOpPromise(promise)` is equivalent to
`{un,}refOp(promise[promiseIdSymbol])`
2023-11-09 13:57:26 -07:00
Divy Srivastava
c4029f6af2
fix(node): implement createPrivateKey (#20981)
Towards #18455
2023-11-09 23:26:59 +05:30
Divy Srivastava
ee7fd0a212
chore(ext/crypto): bump signature to 2.1 (#21125) 2023-11-09 16:15:46 +01:00
Matt Mastracci
f8d1d84c5a
chore(ext/web): migrate to deno_core typed externals (#21114)
Use our safer typed externals for the external required for resource
streams.
2023-11-08 20:46:13 +01:00
Aravind
e4593873a9
fix(ext/http): Throwing Error if the return value of Deno.serve handler is not a Response class (#21099)
---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-11-07 15:52:44 -07:00
David Sherret
7978bc5d1b
fix(node): cjs export analysis should probe for json files (#21113)
Closes #21064
2023-11-07 16:38:55 -05:00
David Sherret
9201198efd
fix(node): inspect ancestor directories when resolving cjs re-exports during analysis (#21104)
If a CJS re-export can't be resolved, it will check the ancestor
directories, which is more similar to what `require` does at runtime.
2023-11-07 09:56:06 -05:00
Gasman
837c870ff4
fix(node/http): socket.setTimeout (#20930)
Fixes #20923
2023-11-07 00:51:14 +01:00
Kenta Moriuchi
90189dd997
fix(ext): use String#toWellFormed in ext/webidl and ext/node (#21054)
Fixes #18802 

This PR adds `util.toUSVString` to node:util:

```js
import util from "node:util";
util.toUSVString("string\ud801"); // => "string\ufffd"
```
2023-11-06 22:18:28 +01:00
Luca Bruno
56a4c981f5
fix(ext/fetch): re-align return type in op_fetch docstring (#21098)
This adds a missing `cancelHandleRid` field in `op_fetch` return type,
see Rust side:

fdb4953ea4/ext/fetch/lib.rs (L183-L189)
2023-11-06 14:15:02 +01:00
Divy Srivastava
4530cd5f0d fix 2023-11-05 06:40:35 -08:00
Divy Srivastava
cbdc649975 fix lint 2023-11-05 06:40:35 -08:00
Divy Srivastava
5202f5460d chore(ext/crypto): upgrade ec crates 2023-11-05 06:40:35 -08:00
Divy Srivastava
46faf37ec0
chore(ext/ffi): use dlopen2 crate (#21093)
Closes #21046
2023-11-05 09:29:26 +00:00
Divy Srivastava
5a45892707
chore: bump deno_native_certs to 0.2 (#21092)
Towards #21046
2023-11-05 08:14:58 +00:00
David Sherret
e4c947dd2b
fix(node): use closest package.json to resolve package.json imports (#21075) 2023-11-04 16:41:51 +00:00
Divy Srivastava
efa1c1c964 chore(ext/crypto): bump curve25519-dalek to 4.1 2023-11-03 20:25:35 -07:00
Igor Zinkovsky
1d0856a4f1
feat(ext/kv): increase checks limit (#21055) 2023-11-02 11:57:11 -07:00
denobot
41877a0b37
1.38.0 (#21051)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-02 01:01:47 +00:00
Bartek Iwańczuk
24c3c96958
feat: granular --unstable-* flags (#20968)
This commit adds granular `--unstable-*` flags:
- "--unstable-broadcast-channel"
- "--unstable-ffi"
- "--unstable-fs"
- "--unstable-http"
- "--unstable-kv"
- "--unstable-net"
- "--unstable-worker-options"
- "--unstable-cron"

These flags are meant to replace a "catch-all" flag - "--unstable", that
gives a binary control whether unstable features are enabled or not. The
downside of this flag that allowing eg. Deno KV API also enables the FFI
API (though the latter is still gated with a permission).

These flags can also be specified in `deno.json` file under `unstable`
key.

Currently, "--unstable" flag works the same way - I will open a follow
up PR that will print a warning when using "--unstable" and suggest to use
concrete "--unstable-*" flag instead. We plan to phase out "--unstable"
completely in Deno 2.
2023-11-01 23:15:08 +01:00
Matt Mastracci
42c426e769
feat(ext/websocket): websockets over http2 (#21040)
Implements `WebSocket` over http/2. This requires a conformant http/2
server supporting the extended connect protocol.

Passes approximately 100 new WPT tests (mostly `?wpt_flags=h2` versions
of existing websockets APIs).

This is implemented as a fallback when http/1.1 fails, so a server that
supports both h1 and h2 WebSockets will still end up on the http/1.1
upgrade path.

The patch also cleas up the websockets handshake to split it up into
http, https+http1 and https+http2, making it a little less intertwined.

This uncovered a likely bug in the WPT test server:
https://github.com/web-platform-tests/wpt/issues/42896
2023-11-01 21:11:01 +00:00
Luca Casonato
d42f154312
feat: disposable Deno resources (#20845)
This commit implements Symbol.dispose and Symbol.asyncDispose for
the relevant resources.

Closes #20839

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-01 20:26:12 +01:00
Igor Zinkovsky
01d3e0f317
feat(cron) implement Deno.cron() (#21019)
This PR adds unstable `Deno.cron` API to trigger execution of cron jobs.

* State: All cron state is in memory. Cron jobs are scheduled according
to the cron schedule expression and the current time. No state is
persisted to disk.
* Time zone: Cron expressions specify time in UTC.
* Overlapping executions: not permitted. If the next scheduled execution
time occurs while the same cron job is still executing, the scheduled
execution is skipped.
* Retries: failed jobs are automatically retried until they succeed or
until retry threshold is reached. Retry policy can be optionally
specified using `options.backoffSchedule`.
2023-11-01 11:57:55 -07:00
Kenta Moriuchi
841f215fd4
fix(ext/node): adapt dynamic type checking to Node.js behavior (#21014) 2023-11-01 16:06:25 +09:00
Leo Kettmeir
39716183ac
feat(ext/web): EventSource (#14730)
Closes #10298

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-10-31 18:16:27 +01:00
Matt Mastracci
e4308aebc0
feat(ext/websocket): use rustls-tokio-stream instead of tokio-rustls (#20518)
Use new https://github.com/denoland/rustls-tokio-stream project instead
of tokio-rustls for direct websocket connections. This library was
written from the ground up to be more reliable and should help with
various bugs that may occur due to underlying bugs in the old library.

Believed to fix #20355, #18977, #20948
2023-10-31 09:34:45 -06:00
Divy Srivastava
edee8ab95d
chore: use deno_whoami (#21027)
Towards #20996 

`deno_whoami` is lightweight on unix and has zero framework dependency
on macOS. https://github.com/denoland/deno_whoami

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-10-31 12:38:39 +00:00
Divy Srivastava
ba6bd444b6
perf: use deno_native_certs crate (#18072)
Fixes #18071 

Replace `rustls_native_certs` which links to Security framework.
https://github.com/denoland/deno_native_certs uses dlopen to lazy load
when needed.
2023-10-31 12:55:46 +01:00
Divy Srivastava
f62e22a699
fix(ext/node): tty streams extends net socket (#21026)
Workaround the circular references issue by using a initializer function
to give tty stream class to `initStdin`.

Fixes https://github.com/denoland/deno/issues/21024
Fixes https://github.com/denoland/deno/issues/20611
Fixes https://github.com/denoland/deno/issues/20890
Fixes https://github.com/denoland/deno/issues/20336

`create-svelte` works now:
```
divy@mini /t/a> ~/gh/deno/target/debug/deno run -A --unstable --reload npm:create-svelte@latest sveltekit-deno

create-svelte version 5.1.1

┌  Welcome to SvelteKit!
│
◇  Which Svelte app template?
│  Skeleton project
│
◇  Add type checking with TypeScript?
│  Yes, using JavaScript with JSDoc comments
│
◇  Select additional options (use arrow keys/space bar)
│  none
│
└  Your project is ready!

✔ Type-checked JavaScript
  https://www.typescriptlang.org/tsconfig#checkJs

Install community-maintained integrations:
  https://github.com/svelte-add/svelte-add

Next steps:
  1: cd sveltekit-deno
  2: npm install
  3: git init && git add -A && git commit -m "Initial commit" (optional)
  4: npm run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat
```

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-10-31 17:24:43 +05:30
Luca Casonato
2d9298f5f5
chore: update ext/kv to use denokv_* crates (#20986)
This commit updates the ext/kv module to use the denokv_* crates for
the protocol and the sqlite backend. This also fixes a couple of bugs in
the sqlite backend, and updates versionstamps to be updated less
linearly.
2023-10-31 11:13:57 +00:00
Matt Mastracci
b75f3b5ca0
feat(ext/websocket): split websocket read/write halves (#20579)
Fixes some UB when sending and receiving at the same time.
2023-10-30 11:49:19 -06:00
Divy Srivastava
09204107d8
fix: implement node:tty (#20892)
Fixes #21012
Closes https://github.com/denoland/deno/issues/20855
Fixes https://github.com/denoland/deno/issues/20890
Fixes https://github.com/denoland/deno/issues/20611
Fixes https://github.com/denoland/deno/issues/20336
Fixes `create-svelte` from https://github.com/denoland/deno/issues/17248

Fixes more reports here:
- https://github.com/denoland/deno/issues/6529#issuecomment-1432690559
- https://github.com/denoland/deno/issues/6529#issuecomment-1522059006
- https://github.com/denoland/deno/issues/6529#issuecomment-1695803570
2023-10-30 15:53:08 +00:00
Divy Srivastava
1acef755ca
chore: remove usage of chrono::Utc::now() (#20995)
Remove usage of Chrono's clock feature which pulls in iana-time-zone ->
core-foundation
2023-10-30 11:45:45 -04:00
Divy Srivastava
02cc37e054
chore: upgrade rsa to 0.9 (#21016) 2023-10-30 16:25:12 +01:00
Divy Srivastava
5b2d9fb8d4
fix(ext/ffi): use anybuffer for op_ffi_buf_copy_into (#21006)
Fixes https://github.com/denoland/deno/issues/21005
2023-10-28 10:02:57 +03:00
Divy Srivastava
4c6b986f17
chore(ext/crypto): upgrade to ring 0.17 (#20824)
Ref https://github.com/denoland/deno/issues/18071
2023-10-27 23:15:09 +02:00
Jared Flatow
33565e16ca
fix(ext/http): patch regression in variadic args to serve handler (#20796)
I'm not sure what was the purpose of trying to be so clever with the
args were (maybe an optimization?), but it breaks variadic args as
pointed out in #20054.

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-27 05:34:41 -06:00
David Sherret
9026f20b2d
fix(unstable/byonm): improve error messages (#20987)
This improves the error messages when a specifier can't be resolved from
a deno module into an npm package.
2023-10-26 21:22:15 -04:00
Bartek Iwańczuk
96ce9cdb17
refactor: op_sleep uses op2 macro (#20908)
Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-26 14:16:41 -06:00
Luca Casonato
08b99f3909
chore: update base64 crate (#20877) 2023-10-26 18:39:04 +02:00
Bartek Iwańczuk
093b3eee58
chore: update deno_core and port all remaining ops to op2 (#20954)
Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-25 13:43:38 +02:00
Jérôme Benoit
9df36b33c6
docs(event): fixlets to code comments (#20944) 2023-10-23 14:34:37 +02:00
sigmaSd
9f9c3d9048
fix(polyfill): correctly handle flag when its equal 0 (#20953)
Fixes https://github.com/denoland/deno/issues/20910
2023-10-22 08:02:55 +00:00
Bartek Iwańczuk
5095af7801
fix(ext/node): process.argv0 (#20925)
Fixes https://github.com/denoland/deno/issues/20924
2023-10-18 01:51:39 +02:00
David Sherret
cb70c4d0c4
fix(node): resolve file.d specifiers in npm packages (#20918)
Makes type checking octokit work.

Closes #20854
2023-10-17 00:26:38 +09:00
Marcos Casagrande
7599990a4f
perf(ext/streams): optimize streams (#20649)
This PR introduces several optimizations to streams

### Highlights:
- `ReadableStream` constructor: +20% iter/s.
- `WritableStream` constructor: +50% iter/s.
- `TransformStream` constructor: +30% iter/s.
- `ReadableStream` iterator (both 2 and 20 chunks): +42% and +25%
iter/s.
- `ReadableByteStream` iterator (both 2 and 20 chunks): +39% and +20%
iter/s.

### Benchmarks
**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)

benchmark                                      time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------------------------- -----------------------------
ReadableStream constructor                    294.52 ns/iter   3,395,392.9 (277.92 ns … 618.26 ns) 292.66 ns 353.87 ns 618.26 ns
WritableStream constructor                    235.51 ns/iter   4,246,065.3 (213.04 ns … 306.35 ns) 236.77 ns 279.08 ns 281.32 ns
TransformStream constructor                   672.52 ns/iter   1,486,938.7 (652.15 ns … 880.74 ns) 670.11 ns 880.74 ns 880.74 ns
ReadableStream - iterator (2 chunks)           10.44 µs/iter      95,757.9   (8.97 µs … 830.91 µs)  10.22 µs  14.74 µs  18.93 µs
ReadableStream - iterator (20 chunks)          21.93 µs/iter      45,593.4   (18.8 µs … 864.97 µs)  20.57 µs  57.15 µs 137.16 µs
ReadableStream - reader (2 chunks)              7.09 µs/iter     140,987.2     (7.03 µs … 7.18 µs)   7.13 µs   7.18 µs   7.18 µs
ReadableStream - reader (20 chunks)            18.41 µs/iter      54,324.2    (15.7 µs … 252.7 µs)  17.14 µs  68.88 µs  94.08 µs
ReadableByteStream - iterator (2 chunks)       11.06 µs/iter      90,375.1   (9.75 µs … 404.69 µs)  10.88 µs   16.6 µs  29.69 µs
ReadableByteStream - iterator (20 chunks)      26.71 µs/iter      37,435.0  (22.98 µs … 508.34 µs)  25.25 µs  85.28 µs 155.65 µs
ReadableByteStream - reader (2 chunks)          7.99 µs/iter     125,131.1     (7.92 µs … 8.13 µs)   8.01 µs   8.13 µs   8.13 µs
ReadableByteStream - reader (20 chunks)        23.46 µs/iter      42,618.5  (20.28 µs … 414.66 µs)  21.94 µs  90.52 µs 147.38 µs
```

**this PR**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)

benchmark                                      time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------------------------- -----------------------------
ReadableStream constructor                    235.48 ns/iter   4,246,584.3 (223.12 ns … 504.65 ns)  234.3 ns 290.84 ns 311.12 ns
WritableStream constructor                    156.31 ns/iter   6,397,537.3 (148.54 ns … 211.13 ns) 157.49 ns 199.82 ns 208.23 ns
TransformStream constructor                   471.29 ns/iter   2,121,815.3 (452.53 ns … 791.41 ns) 468.62 ns 540.36 ns 791.41 ns
ReadableStream - iterator (2 chunks)            7.32 µs/iter     136,705.4   (6.35 µs … 639.97 µs)    7.1 µs  12.12 µs  20.98 µs
ReadableStream - iterator (20 chunks)          17.48 µs/iter      57,195.1  (14.48 µs … 289.06 µs)  16.06 µs  76.98 µs 114.61 µs
ReadableStream - reader (2 chunks)              6.86 µs/iter     145,847.9      (6.8 µs … 6.97 µs)   6.88 µs   6.97 µs   6.97 µs
ReadableStream - reader (20 chunks)            16.88 µs/iter      59,227.7  (14.04 µs … 311.29 µs)  15.39 µs  74.95 µs  97.45 µs
ReadableByteStream - iterator (2 chunks)        7.94 µs/iter     125,881.2   (6.86 µs … 811.16 µs)   7.69 µs  11.43 µs   16.6 µs
ReadableByteStream - iterator (20 chunks)      22.23 µs/iter      44,978.2  (18.98 µs … 590.11 µs)  20.73 µs  45.13 µs  159.8 µs
ReadableByteStream - reader (2 chunks)           7.4 µs/iter     135,206.9     (7.36 µs … 7.42 µs)    7.4 µs   7.42 µs   7.42 µs
ReadableByteStream - reader (20 chunks)        21.03 µs/iter      47,555.6  (17.75 µs … 357.66 µs)  19.52 µs  98.69 µs  146.5 µs
```

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-10-13 14:30:09 +02:00
denobot
5da1bd802c
chore: forward v1.37.2 release commit to main (#20897)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-13 03:12:06 +00:00
Bartek Iwańczuk
c464cd7073
refactor: FeatureChecker integration in ext/ crates (#20797)
Towards https://github.com/denoland/deno/issues/20779.
2023-10-12 15:55:50 +00:00
Bartek Iwańczuk
cee221109a
fix(node/http2): fixes to support grpc (#20712)
This commit improves "node:http2" module implementation, by enabling
to use "options.createConnection" callback when starting an HTTP2
session.
This change enables to pass basic client-side test with "grpc-js/grpc"
package.
Smaller fixes like "Http2Session.unref()" and "Http2Session.setTimeout()"
were handled as well.

Fixes #16647
2023-10-12 14:03:19 +00:00
Leo Kettmeir
8ba1242a05
feat(WebSocketStream): rename connection to opened (#20878) 2023-10-11 07:31:05 +02:00
Luca Casonato
6450334f5b
feat(ext/web): cancel support for TransformStream (#20815) 2023-10-10 18:42:31 +09:00
Luca Casonato
2665ca103e
fix(ext/web): writability of ReadableStream.from (#20836)
Fixes a WPT in `URL` and `ReadableStream`.

Some unrelated WPT expectation changes due to WPT update.
2023-10-10 05:01:01 +02:00
Luca Casonato
ae81065c75
fix(ext/http): Deno.Server should not be thenable (#20723)
Otherwise you can not return `Deno.Server` from async functions.

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-09 12:43:14 +09:00
Bartek Iwańczuk
2167a52d69
refactor: remove TimersPermissions::check_unstable (#20831)
This is dead code that was not used in any way.

Ref https://github.com/denoland/deno/pull/20797
2023-10-09 02:08:10 +02:00
Matt Mastracci
6cb5d8eb86
fix(ext/ffi): use anybuffer for op_ffi_ptr_of (#20820)
Fixes #20817
2023-10-08 14:02:07 +09:00
Aapo Alasuutari
effb5e1ce4
fix(node/buffer): utf8ToBytes should return a Uint8Array (#20769) 2023-10-08 11:09:50 +09:00
Bartek Iwańczuk
edeccef499
refactor: migrate more ops to op2 macro (#20808)
Getting closer...
2023-10-07 21:04:03 +05:30
Marcos Casagrande
ceecd8c495
perf(ext/web): optimize structuredClone without transferables (#20730)
This PR optimizes `structuredClone` when it's called without
transferables.

### Benchmarks

**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)

benchmark                          time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------------- -----------------------------
structuredClone object              1.64 µs/iter     611,086.0     (1.58 µs … 1.84 µs)   1.66 µs   1.84 µs   1.84 µs
structuredClone transferables       2.82 µs/iter     354,281.4     (2.78 µs … 2.92 µs)   2.84 µs   2.92 µs   2.92 µs
```

**this PR**

```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)

structuredClone object                 1 µs/iter     998,383.5    (971.28 ns … 1.2 µs)      1 µs    1.2 µs    1.2 µs
structuredClone transferables       2.82 µs/iter     355,087.5      (2.7 µs … 3.07 µs)   2.83 µs   3.07 µs   3.07 µs
```

```js
Deno.bench("structuredClone object", () => {
  structuredClone({ foo: "bar" });
});

Deno.bench("structuredClone transferables", () => {
  const buf = new Uint8Array([97]);
  structuredClone(buf, {
    transfer: [buf.buffer],
  });
});
```
2023-10-06 23:21:48 +02:00
Bartek Iwańczuk
f0608a5b91
refactor: migrate ext/node/ops to op2 (#20805) 2023-10-06 00:16:36 +02:00
David Sherret
820e93e3e7
refactor(npm): add referrer when resolving npm package sub path from deno module (#20800)
Adds a `referrer` parameter to this function instead of using a fake
one.
2023-10-05 20:18:29 +00:00
林炳权
7a01799f49
chore: update to Rust 1.73 (#20781) 2023-10-05 14:49:09 -04:00
Divy Srivastava
ab3c9d41e4
fix(ext/node): implement uv.errname (#20785)
Fixes https://github.com/denoland/deno/issues/20617
2023-10-05 18:27:20 +00:00
Marcos Casagrande
176bf9ba5f
fix(ext/formdata): support multiple headers in FormData (#20801)
Fixes https://github.com/denoland/deno/issues/20793
2023-10-05 19:28:44 +02:00
Matt Mastracci
1619932a65
chore(ext/ffi): migrate from op -> op2 for ffi (#20509)
Migrate to op2. Making a few decisions to get this across the line:

- Empty slices, no matter where the come from, are null pointers. The v8
bugs (https://bugs.chromium.org/p/v8/issues/detail?id=13489) and
(https://bugs.chromium.org/p/v8/issues/detail?id=13488) make passing
around zero-length slice pointers too dangerous as they might be
uninitialized or null data.
- Offsets and lengths are `#[number] isize` and `#[number] usize`
respectively -- 53 bits should be enough for anyone
- Pointers are bigints. This is a u64 in the fastcall world, and can
accept Integer/Int32/Number/BigInt v8 types in the slow world.
2023-10-05 15:35:21 +02:00
Bartek Iwańczuk
5d98a544b4
refactor: rewrite several extension ops to op2 (#20457)
Rewrites following extensions:
- `ext/web`
- `ext/url`
- `ext/webstorage`
- `ext/io`

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-05 14:34:38 +02:00
David Sherret
1ff525e25b
refactor(node): combine node resolution code for resolving a package subpath from external code (#20791)
We had two methods that did the same functionality.
2023-10-04 23:05:12 -04:00
Divy Srivastava
1a81b2826d
refactor: rewrite websocket to use op2 macro (#20140)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-04 21:43:58 +00:00
Bartek Iwańczuk
a5568066b3
refactor: use deno_core::FeatureChecker for unstable checks (#20765) 2023-10-04 21:42:17 +02:00
Yoshiya Hinosawa
da0b945804
feat(unstable): add unix domain socket support to Deno.serve (#20759) 2023-10-04 11:37:39 +09:00
David Sherret
8c1677ecbc
refactor(npm): break up NpmModuleLoader and move more methods into the managed CliNpmResolver (#20777)
Part of https://github.com/denoland/deno/issues/18967
2023-10-03 19:05:06 -04:00
Luca Casonato
d5b6c636b0
fix(ext/node): don't call undefined nextTick fn (#20724)
The `process` global is not defined in this file.

Fixes #20441

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-02 14:13:57 +02:00
Marcos Casagrande
de25c81fd0
perf(ext/web): optimize DOMException (#20715)
This PR optimizes `DOMException` constructor increasing performance of
all Web APIs that throw a `DOMException` (ie: `AbortSignal`)

**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)

new DOMException()            9.66 µs/iter     103,476.8   (8.47 µs … 942.71 µs)   9.62 µs  11.29 µs  14.04 µs
abort writeTextFileSync      16.45 µs/iter      60,775.5    (13.65 µs … 1.33 ms)  16.39 µs  20.59 µs  24.12 µs
abort readFile               16.25 µs/iter      61,542.2  (15.12 µs … 621.14 µs)  16.18 µs  19.59 µs  22.33 µs
```

**this PR**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)

benchmark                    time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------- -----------------------------
new DOMException()            2.37 µs/iter     421,657.0     (2.33 µs … 2.58 µs)   2.37 µs   2.58 µs   2.58 µs
abort writeTextFileSync        7.1 µs/iter     140,760.1     (6.94 µs … 7.68 µs)   7.13 µs   7.68 µs   7.68 µs
abort readFile                5.48 µs/iter     182,648.2      (5.3 µs … 5.69 µs)   5.56 µs   5.69 µs   5.69 µ
```

```js
Deno.bench("new DOMException()", () => {
  new DOMException();
});

Deno.bench("abort writeTextFileSync", () => {
  const ac = new AbortController();
  ac.abort();
  try {
    Deno.writeTextFileSync("/tmp/out", "x", { signal: ac.signal });
  } catch {}
});

Deno.bench("abort readFile", async () => {
  const ac = new AbortController();
  ac.abort();
  try {
    await Deno.readFile("/tmp/out", { signal: ac.signal });
  } catch {}
});
```
2023-10-02 02:18:34 +02:00
Divy Srivastava
1cda3840ff
perf(node): use faster utf8 byte length in Buffer#from (#20746)
Use the `core.byteLength` op for string utf8 length calculation in
`node:buffer`

```
# This patch
file:///Users/divy/gh/deno/buffer.mjs
benchmark        time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer#from     272.11 ns/iter   3,675,029.3 (268.41 ns … 301.15 ns) 271.62 ns  295.5 ns 301.15 ns

# Deno 1.37.1
file:///Users/divy/gh/deno/buffer.mjs
benchmark        time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer#from     411.28 ns/iter   2,431,428.8 (393.82 ns … 439.92 ns) 418.85 ns  434.4 ns 439.92 ns
```
2023-09-30 20:04:40 +05:30
Rui He
74e4c7f80f
feat(node/os): Add availableParallelism (#20745) 2023-09-30 19:51:06 +05:30
Igor Zinkovsky
61b91e10ad
fix(ext/kv): send queue wake messages accross different kv instances (#20465)
fixes #20454

Current KV queues implementation assumes that `enqueue` and
`listenQueue` are called on the same instance of `Deno.Kv`. It's
possible that the same Deno process opens multiple KV instances pointing
to the same fs path, and in that case `listenQueue` should still get
notified of messages enqueued through a different KV instance.
2023-09-29 11:40:36 -07:00
David Sherret
d43e48c4e9
refactor(ext/node): remove dependency on deno_npm and deno_semver (#20718)
This is required from BYONM (bring your own node_modules).

Part of #18967
2023-09-28 22:43:45 +02:00
Matt Mastracci
8ef52b3e6a
chore(ext/ffi): migrate part of FFI to op2 (#20699) 2023-09-27 07:54:43 -06:00
Chen Su
507f24c474
fix(ext/node): fix TypeError in Buffer.from with base64url encoding. (#20705)
For the following example, if I set the encoding to `base64url`, it'll
throw an unexpected TypeError:

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

Buffer.from("IntcImhlbGxvXCI6XCJoZGQvZStpXCJ9Ig", "base64url").toString();

// error: Uncaught TypeError: src.subarray is not a function
// const buf = Buffer.from(
//                    ^
//     at blitBuffer (ext:deno_node/internal/buffer.mjs:1779:15)
//     at Uint8Array.base64urlWrite (ext:deno_node/internal/buffer.mjs:691:10)
//     at Object.write (ext:deno_node/internal/buffer.mjs:2195:11)
//     at Uint8Array.write (ext:deno_node/internal/buffer.mjs:794:14)
//     at fromString (ext:deno_node/internal/buffer.mjs:214:22)
//     at _from (ext:deno_node/internal/buffer.mjs:119:12)
//     at Function.from (ext:deno_node/internal/buffer.mjs:157:10)
//     at file:///Users/foodieats/temp/buffer1.ts:3:20
```

The error caused by `base64urlWrite` function, it should call
`forgivingBase64UrlDecode` not `forgivingBase64UrlEncode`

Also fixed #20563 .
2023-09-27 07:54:19 -06:00
denobot
3b78981ffe
chore: forward v1.37.1 release commit to main (#20706)
This is the release commit being forwarded back to main for 1.37.1

Co-authored-by: littledivy <littledivy@users.noreply.github.com>
2023-09-27 09:13:48 +00:00
Heyang Zhou
f58a400585
feat(ext/kv): support key expiration in remote backend (#20688)
This patch adds support for [key
expiration](https://docs.deno.com/kv/manual/key_expiration) in the
remote backend.
2023-09-27 13:34:09 +08:00
Igor Zinkovsky
f0a022bed4
fix(kv_queues): graceful shutdown (#20627)
This fixes the `TypeError: Database closed` error during shutdown.
2023-09-26 20:06:57 -07:00
David Sherret
dcb00bb9b8
chore: slight cleanup in npm resolvers (#20692) 2023-09-26 16:42:39 -04:00
Bartek Iwańczuk
3c0d6de155
refactor: rewrite ext/node/crypto to op2 macro (#20675) 2023-09-26 12:07:04 +00:00
Laurence Rowe
8fcea5966c
refactor(ext/http): use scopeguard defer to handle async drop (#20652)
Use the [scopeguard](https://docs.rs/scopeguard/) defer macro to run
cleanup code for `new_slab_future`.
This means it can be a single async function, avoiding the need to
create a struct and implement `PinnedDrop`

Async cleanup in Rust is awkward because async functions may be
cancelled at any await point when their Future is dropped.
The scopeguard approach comes from the following articles:
* [How to think about `async`/`await` in
Rust](http://cliffle.com/blog/async-inversion/)
* [Async Cancellation
I](https://blog.yoshuawuyts.com/async-cancellation-1/) (Reddit
[discussion](https://www.reddit.com/r/rust/comments/qrhg39/blog_post_async_cancellation/))
2023-09-26 05:42:48 -06:00
Matt Mastracci
a27ee8f368
fix(ext/http): ensure that resources are closed when request is cancelled (#20641)
Builds on top of #20622 to fix #10854
2023-09-25 17:23:55 +02:00
Bartek Iwańczuk
b2abae4771
refactor: rewrite more ops to op2 (#20666) 2023-09-24 22:07:22 +00:00
Aapo Alasuutari
cb9ab9c3ac
fix(ext/node): Fix invalid length variable reference in blitBuffer (#20648) 2023-09-24 13:48:23 +03:00
Mikhail
0e2637f851
fix(ext/node): simplified array.from + map (#20653)
`Array.from` has optional second argument. Calling `map` is not required
for this case.
2023-09-24 11:23:25 +02:00
Bartek Iwańczuk
68851d6f37
refactor: rewrite ops to op2 macro (#20628)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-09-23 19:33:31 +00:00
Bartek Iwańczuk
99dd8097c3
refactor: rewrite ext/node/http2 to op2 macro (#20629) 2023-09-23 10:25:36 -06:00
Matt Mastracci
06297d952d
feat(ext/web): use readableStreamDefaultReaderRead in resourceForReadableStream (#20622)
We can go one level down in abstraction and avoid using the public
`ReadableStream` APIs.

This patch ~5% perf boost on small ReadableStream:

```
Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   148.32us  108.95us   3.88ms   95.71%
    Req/Sec    33.24k     2.68k   37.94k    73.76%
  668188 requests in 10.10s, 77.74MB read
Requests/sec:  66162.91
Transfer/sec:      7.70MB
```

main:

```
Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   150.23us   67.61us   4.39ms   94.80%
    Req/Sec    31.81k     1.55k   35.56k    83.17%
  639078 requests in 10.10s, 74.36MB read
Requests/sec:  63273.72
Transfer/sec:      7.36MB
```
2023-09-23 14:55:28 +00:00
Bartek Iwańczuk
1ad097c4bf
refactor: rewrite ops using i64/usize to op2 (#20647) 2023-09-23 14:04:47 +02:00
Divy Srivastava
75a724890d
fix(node): supported arguments to randomFillSync (#20637)
Fixes https://github.com/denoland/deno/issues/20634
2023-09-23 10:04:55 +02:00
Igor Zinkovsky
035df85732
feat(kv_queues): increase max queue delay to 30 days (#20626) 2023-09-22 09:40:35 -07:00
Alessandro Scandone
15cfb67551
fix(node/package_json): Avoid panic when "exports" field is null (#20588)
Fixes #20558

Implementation: when package.json `exports` field is `null`, treat it as
if it was not set
2023-09-22 11:21:38 +02:00
Marcos Casagrande
65a94a6176
perf(ext/fetch): use new instead of createBranded (#20624)
This PR optimizes `fromInner*` methods of `Request` / `Header` /
`Response` used by `Deno.serve` and `fetch` by using `new` instead of
`ObjectCreate` from `createBranded`.

The "brand" is created by passing `webidl.brand` to the constructor
instead.


142449ecab/ext/webidl/00_webidl.js (L1001-L1005)

### Benchmark
```js
const createBranded = Symbol("create branded");
const brand = Symbol("brand");
class B {
  constructor(init) {
    if (init === createBranded) {
      this[brand] = brand;
    }
  }
}

Deno.bench("Object.create(protoype)", () => {
  Object.create(B.prototype);
});

Deno.bench("new Class", () => {
  new B(createBranded);
});
```

```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)

benchmark                    time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------- -----------------------------
Object.create(protoype)       8.74 ns/iter 114,363,610.3    (7.32 ns … 26.02 ns)   8.65 ns  13.39 ns  14.47 ns
new Class                     3.05 ns/iter 328,271,012.2      (2.78 ns … 9.1 ns)   3.06 ns   3.46 ns    3.5 ns
```
2023-09-21 20:06:42 -06:00
Bartek Iwańczuk
142449ecab
refactor: rewrite some ops to op2 macro (#20603) 2023-09-21 08:08:23 -06:00
Divy Srivastava
cf6f649829
fix(node): point process.version to Node 18.18.0 LTS (#20597)
Fixes https://github.com/denoland/deno/issues/20590
2023-09-21 06:44:37 +00:00
Matt Mastracci
0981aefbdc
fix(ext/web): Aggregate small packets for Resource implementation of ReadableStream (#20570)
Fixes: #20569 by introducing a custom replacement for the tokio mpsc
channel that is byte-size backpressure-aware.

Using the testcase in the linked bug, we see all the small writes
aggregated into a single packet and HTTP frame.

```
10:39 $ nc localhost 8000
GET / HTTP/1.1

HTTP/1.1 200 OK
content-type: text/plain
vary: Accept-Encoding
transfer-encoding: chunked
date: Tue, 19 Sep 2023 16:39:13 GMT

A
0
1
2
3
4
```

This patch:

```
Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   157.47us  194.89us   9.53ms   98.97%
    Req/Sec    31.37k     1.56k   34.73k    85.15%
  630407 requests in 10.10s, 73.35MB read
Requests/sec:  62428.12
Transfer/sec:      7.26MB
```

main:

```
Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   343.75us  200.48us  10.41ms   98.25%
    Req/Sec    14.64k   806.52    16.98k    84.65%
  294018 requests in 10.10s, 39.82MB read
Requests/sec:  29109.91
Transfer/sec:      3.94MB
```

---------

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2023-09-20 11:23:58 -06:00
Bartek Iwańczuk
d77f3fba03
refactor: rewrite BC, cache exts to op2 (#20486)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-09-19 20:39:27 -06:00
denobot
997aa604df
1.37.0 (#20574)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-09-19 20:29:17 +00:00
Matt Mastracci
612818d043
fix(cli): ensure that an exception in getOwnPropertyDescriptor('constructor') doesn't break Deno.inspect (#20568)
Fixes #20561
2023-09-19 18:24:19 +00:00
Marcos Casagrande
4960b6659c
perf(ext/streams): optimize async iterator (#20541)
This PR optimizes `ReadableStream` async iterator

### Benchmarks

```js
Deno.bench("Stream - iterator", async () => {
  const stream = new ReadableStream({
    start(controller) {
      controller.enqueue(new Uint8Array([97]));
      controller.enqueue(new Uint8Array([97]));
      controller.close();
    },
  });

  for await (const chunk of stream) {}
});
```

**main**

`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)

benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      12.45 µs/iter      80,295.5   (10.5 µs … 281.12 µs)  12.13 µs  26.71 µs  33.63 µs
```
`20 chunks`

```
benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      32.99 µs/iter      30,312.2    (28.13 µs … 1.21 ms)   31.8 µs  81.82 µs 179.93 µs
```
---

**this PR**

`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)

benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator       9.37 µs/iter     106,700.8   (8.35 µs … 730.71 µs)   9.15 µs  13.12 µs  18.17 µs
```
`20 chunks`
```
benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      16.59 µs/iter      60,270.0    (12.08 µs … 1.37 ms)  15.06 µs  83.03 µs 123.52 µs
```
2023-09-17 15:54:40 +00:00
Marcos Casagrande
16b7c9cd8d
perf(ext/http): optimize set_response for small responses (#20527)
This PR introduces an optimization to `set_response` to reduce the
overhead for responses with a payload size less than 64 bytes.
Performance gains are more noticeable when `is_request_compressible`
enters the slow path, ie: `-H 'Accept-Encoding: unknown'`

### Benchmarks
```js
Deno.serve({ port: 3000 }, () => new Response("hello"));
```
```
wrk -d 10s --latency -H 'Accept-Encoding: slow' http://127.0.0.1:3000
```
---
**main**
```
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    44.72us   28.12us   3.10ms   97.95%
    Req/Sec   112.73k     8.25k  123.66k    91.09%
  2264092 requests in 10.10s, 308.77MB read
Requests/sec: 224187.08
Transfer/sec:     30.57MB
```
**this PR**
```
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    42.91us   20.57us   2.04ms   97.36%
    Req/Sec   116.61k     7.95k  204.81k    88.56%
  2330970 requests in 10.10s, 317.89MB read
Requests/sec: 230806.32
Transfer/sec:     31.48MB
```
2023-09-16 15:15:15 -06:00
Luca Casonato
430b63c2c4
perf: improve async op santizer speed and accuracy (#20501)
This commit improves async op sanitizer speed by only delaying metrics
collection if there are pending ops. This
results in a speedup of around 30% for small CPU bound unit tests.

It performs this check and possible delay on every collection now,
fixing an issue with parent test leaks into steps.
2023-09-16 07:48:31 +02:00
Bartek Iwańczuk
bf07604113
feat: Add "deno jupyter" subcommand (#20337)
This commit adds "deno jupyter" subcommand which
provides a Deno kernel for Jupyter notebooks.

The implementation is mostly based on Deno's REPL and
reuses large parts of it (though there's some clean up that
needs to happen in follow up PRs). Not all functionality of
Jupyter kernel is implemented and some message type
are still not implemented (eg. "inspect_request") but
the kernel is fully working and provides all the capatibilities
that the Deno REPL has; including TypeScript transpilation
and npm packages support.

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

---------

Co-authored-by: Adam Powers <apowers@ato.ms>
Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
2023-09-16 02:42:09 +02:00
Bartek Iwańczuk
5a1505db67
feat(ext/node): http2.connect() API (#19671)
This commit improves compatibility of "node:http2" module by polyfilling
"connect" method and "ClientHttp2Session" class. Basic operations like
streaming, header and trailer handling are working correctly. 
Refing/unrefing is still a TODO and "npm:grpc-js/grpc" is not yet working
correctly.

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-09-15 21:51:25 +02:00
Matt Mastracci
71af3c375c
fix(ext/http): ensure aborted bodies throw (#20503)
Fixes #20502 -- ensure that Hyper errors make it through to JS.
2023-09-15 08:08:21 -06:00
Bartek Iwańczuk
5e7435fb80
refactor: rewrite more ops to op2 macro (#20478) 2023-09-14 23:05:18 +02:00
Bartek Iwańczuk
bbb348aa33
refactor: rewrite ext/node to op2 (#20489) 2023-09-14 08:29:44 +02:00
lionel-rowe
2046aeed70
feat(ext/web): Add name to Deno.customInspect of File objects (#20415)
Fixes https://github.com/denoland/deno/issues/20414
2023-09-14 07:06:58 +02:00
David Sherret
e60cbfadc0
refactor: use TaskQueue from deno_unsync (#20485) 2023-09-13 23:36:24 -04:00
Matt Mastracci
81d50e1b66
chore: bump deno_core and cargo update (#20480)
Bump deno_core, pulling in new rusty_v8. Requires some op2/deprecation
fixes.
2023-09-13 22:01:31 +00:00
Bartek Iwańczuk
109a42ab07
refactor: rewrite ext/crypto to op2 (#20477) 2023-09-13 17:54:19 +02:00
Bartek Iwańczuk
08d2a32060
refactor: rewrite ext/net/ ops to op2 (#20471) 2023-09-12 15:39:21 +02:00
Bartek Iwańczuk
f32acb945e
refactor: rewrite ext/io, ext/webstorage ops to op2 (#20461) 2023-09-12 12:42:05 +02:00
Matt Mastracci
950e0e9cd6
fix(ext/http): create a graceful shutdown API (#20387)
This PR implements a graceful shutdown API for Deno.serve, allowing all
current connections to drain from the server before shutting down, while
preventing new connections from being started or new transactions on
existing connections from being created.

We split the cancellation handle into two parts: a listener handle, and
a connection handle. A graceful shutdown cancels the listener only,
while allowing the connections to drain. The connection handle aborts
all futures. If the listener handle is cancelled, we put the connections
into graceful shutdown mode, which disables keep-alive on http/1.1 and
uses http/2 mechanisms for http/2 connections.

In addition, we now guarantee that all connections are complete or
cancelled, and all resources are cleaned up when the server `finished`
promise resolves -- we use a Rust-side server refcount for this.

Performance impact: does not appear to affect basic serving performance
by more than 1% (~126k -> ~125k)

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-09-12 00:06:38 +00:00
Matt Mastracci
bfd230fd78
chore: update inner #\![allow] to #[allow] (#20463)
Functions should generally be annotated with `#[allow]` blocks rather
than using inner `#![allow]` annotations.
2023-09-11 17:12:33 -06:00
Bartek Iwańczuk
aaff69db3f
perf(node/net): optimize socket reads for 'npm:ws' package (#20449)
Fixes performance regression introduced by
https://github.com/denoland/deno/pull/20223 and
https://github.com/denoland/deno/pull/20314. It's enough to have one
"shared" buffer per socket
and no locking mechanism is required.
2023-09-11 20:38:57 +02:00
Heyang Zhou
375d8a5bd5
fix(ext/kv): same expireIn should generate same expireAt (#20396)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-09-08 23:20:28 +08:00
Curran McConnell
a9cc4631ca
fix(ext/node/ops/zlib/brotli): Allow decompressing more than 4096 bytes (#20301)
Fixes https://github.com/denoland/deno/issues/19816

In that issue, I suggest switching over the other brotli functionality
to the Rust API provided by the `brotli` crate. Here, I only do that
with the `brotli_decompress` function to fix the bug with buffers longer
than 4096 bytes.
2023-09-08 09:11:33 +05:30
Aapo Alasuutari
9d6584c16f
perf(ext/node): Optimise Buffer string operations (#20158)
Extracted from https://github.com/denoland/deno/pull/17815

Optimise Buffer's string operations, most significantly when dealing
with ASCII and UTF-16. Base64 and HEX encodings are affected to much
lesser degrees.

## Performance

### String length 15
With very small strings we're at break-even or sometimes even lose a tad
bit of performance from creating a `DataView` that ends up not paying
for itself.

**This PR:**
```
benchmark                                                     time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                       1.15 µs/iter     871,388.6   (728.78 ns … 1.56 µs)   1.23 µs   1.56 µs   1.56 µs
Buffer.from base64 string                                      1.63 µs/iter     612,790.9     (1.31 µs … 1.96 µs)   1.77 µs   1.96 µs   1.96 µs
Buffer.from utf16 string                                       1.41 µs/iter     707,396.3   (915.24 ns … 1.93 µs)   1.61 µs   1.93 µs   1.93 µs
Buffer.from hex string                                         1.87 µs/iter     535,357.9     (1.56 µs … 2.19 µs)      2 µs   2.19 µs   2.19 µs
Buffer.toString ascii string                                 154.58 ns/iter   6,469,162.8    (149.69 ns … 198 ns) 154.51 ns 182.89 ns 191.91 ns
Buffer.toString base64 string                                161.65 ns/iter   6,186,189.6 (150.91 ns … 181.15 ns) 165.18 ns 171.87 ns 174.94 ns
Buffer.toString utf16 string                                 292.74 ns/iter   3,415,959.8 (285.43 ns … 312.47 ns) 295.25 ns 310.47 ns 312.47 ns
Buffer.toString hex string                                    89.61 ns/iter  11,159,315.6  (81.09 ns … 123.77 ns)  91.09 ns 113.62 ns 119.28 ns
```

**Main:**
```
benchmark                                                     time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                       1.26 µs/iter     794,875.8     (1.07 µs … 1.46 µs)   1.31 µs   1.46 µs   1.46 µs
Buffer.from base64 string                                      1.65 µs/iter     607,853.3     (1.38 µs … 2.01 µs)   1.69 µs   2.01 µs   2.01 µs
Buffer.from utf16 string                                       1.34 µs/iter     744,894.6     (1.09 µs … 1.55 µs)   1.45 µs   1.55 µs   1.55 µs
Buffer.from hex string                                         2.01 µs/iter     496,345.8      (1.54 µs … 2.6 µs)   2.26 µs    2.6 µs    2.6 µs
Buffer.toString ascii string                                 150.16 ns/iter   6,659,630.5 (144.99 ns … 166.68 ns)  152.4 ns 157.26 ns 159.14 ns
Buffer.toString base64 string                                164.73 ns/iter   6,070,692.0 (158.77 ns … 185.63 ns) 168.48 ns 175.74 ns 176.68 ns
Buffer.toString utf16 string                                 150.61 ns/iter   6,639,864.0  (148.2 ns … 168.29 ns) 150.93 ns 157.21 ns 168.15 ns
Buffer.toString hex string                                    94.21 ns/iter  10,614,972.9   (86.21 ns … 98.75 ns)  95.43 ns  97.99 ns  98.21 ns
```

### String length 1500
With moderate lengths we already see great upsides for `Buffer.from()`
with ASCII and UTF-16.

**This PR:**
```
benchmark                                                     time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                       5.79 µs/iter     172,562.6     (4.72 µs … 4.71 ms)   5.04 µs   10.3 µs  11.67 µs
Buffer.from base64 string                                      5.08 µs/iter     196,678.9     (4.97 µs … 5.76 µs)   5.08 µs   5.76 µs   5.76 µs
Buffer.from utf16 string                                       9.68 µs/iter     103,316.5     (7.14 µs … 3.44 ms)  10.32 µs  13.42 µs  15.21 µs
Buffer.from hex string                                         53.7 µs/iter      18,620.2     (49.37 µs … 2.2 ms)  54.74 µs   72.2 µs  81.07 µs
Buffer.toString ascii string                                   6.63 µs/iter     150,761.3     (5.59 µs … 1.11 ms)   6.08 µs  15.68 µs  24.77 µs
Buffer.toString base64 string                                460.57 ns/iter   2,171,224.4 (448.33 ns … 511.73 ns) 465.05 ns 495.54 ns 511.73 ns
Buffer.toString utf16 string                                   6.52 µs/iter     153,287.0     (6.47 µs … 6.66 µs)   6.53 µs   6.66 µs   6.66 µs
Buffer.toString hex string                                     3.68 µs/iter     271,965.4     (3.64 µs … 3.82 µs)   3.68 µs   3.82 µs   3.82 µs
```

**Main:**
```
benchmark                                                     time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                      11.46 µs/iter      87,298.1    (8.53 µs … 834.1 µs)   9.61 µs  83.31 µs   87.3 µs
Buffer.from base64 string                                       5.4 µs/iter     185,027.8     (5.07 µs … 7.49 µs)   5.44 µs   7.49 µs   7.49 µs
Buffer.from utf16 string                                       20.3 µs/iter      49,270.8  (13.55 µs … 649.11 µs)   18.8 µs 113.93 µs 125.17 µs
Buffer.from hex string                                        52.03 µs/iter      19,218.9    (48.74 µs … 2.59 ms)  52.84 µs  67.05 µs  73.56 µs
Buffer.toString ascii string                                   6.46 µs/iter     154,822.5     (6.32 µs … 6.69 µs)   6.52 µs   6.69 µs   6.69 µs
Buffer.toString base64 string                                440.19 ns/iter   2,271,764.6    (427 ns … 490.77 ns) 444.74 ns 484.64 ns 490.77 ns
Buffer.toString utf16 string                                   6.89 µs/iter     145,106.7     (6.81 µs … 7.24 µs)   6.91 µs   7.24 µs   7.24 µs
Buffer.toString hex string                                     3.66 µs/iter     273,456.5      (3.6 µs … 4.02 µs)   3.64 µs   4.02 µs   4.02 µs
```

### String length 2^20
With massive lengths we the difference in ASCII and UTF-16 parsing
performance is enormous.

**This PR:**
```
benchmark                                                           time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                              4.1 ms/iter         243.7     (2.64 ms … 6.74 ms)   4.43 ms   6.26 ms   6.74 ms
Buffer.from base64 string                                            3.74 ms/iter         267.6     (2.91 ms … 4.92 ms)   3.96 ms   4.31 ms   4.92 ms
Buffer.from utf16 string                                             7.72 ms/iter         129.5    (5.91 ms … 11.03 ms)   7.97 ms  11.03 ms  11.03 ms
Buffer.from hex string                                              35.72 ms/iter          28.0   (34.71 ms … 38.42 ms)  35.93 ms  38.42 ms  38.42 ms
Buffer.toString ascii string                                        78.92 ms/iter          12.7   (42.72 ms … 94.13 ms)  91.64 ms  94.13 ms  94.13 ms
Buffer.toString base64 string                                      833.62 µs/iter       1,199.6   (638.05 µs … 5.97 ms) 826.86 µs   2.45 ms   2.48 ms
Buffer.toString utf16 string                                        79.35 ms/iter          12.6    (69.72 ms … 88.9 ms)  86.66 ms   88.9 ms   88.9 ms
Buffer.toString hex string                                          31.04 ms/iter          32.2      (4.3 ms … 46.9 ms)  37.21 ms   46.9 ms   46.9 ms
```

**Main:**
```
benchmark                                                           time (avg)        iter/s             (min … max)       p75       p99      p995
-------------------------------------------------------------------------------------------------------------------- -----------------------------
Buffer.from ascii string                                            18.66 ms/iter          53.6   (15.61 ms … 23.26 ms)  20.62 ms  23.26 ms  23.26 ms
Buffer.from base64 string                                             4.7 ms/iter         212.9     (2.94 ms … 9.07 ms)   4.65 ms   9.06 ms   9.07 ms
Buffer.from utf16 string                                            33.49 ms/iter          29.9   (31.24 ms … 35.67 ms)  34.08 ms  35.67 ms  35.67 ms
Buffer.from hex string                                              39.38 ms/iter          25.4   (38.66 ms … 42.36 ms)  39.58 ms  42.36 ms  42.36 ms
Buffer.toString ascii string                                        77.68 ms/iter          12.9   (67.46 ms … 95.68 ms)  84.71 ms  95.68 ms  95.68 ms
Buffer.toString base64 string                                      825.53 µs/iter       1,211.3   (655.38 µs … 6.69 ms) 816.62 µs   3.07 ms   3.13 ms
Buffer.toString utf16 string                                        76.54 ms/iter          13.1    (66.9 ms … 85.26 ms)  83.63 ms  85.26 ms  85.26 ms
Buffer.toString hex string                                          38.56 ms/iter          25.9   (33.83 ms … 46.56 ms)  45.33 ms  46.56 ms  46.56 ms
```
2023-09-07 14:41:16 -06:00
Matt Mastracci
29784df24e
chore(ext/fs): port some ops to op2 (#20402)
Port as many of these ops as we can to `op2`. Waiting on a few
`deno_core` updates to complete this file.
2023-09-07 13:19:20 -06:00
Matt Mastracci
9226207c01
chore(ext/node): port some ops to op2 (#20400) 2023-09-07 10:56:02 -06:00
David Sherret
3fc19dab47
feat: support import attributes (#20342) 2023-09-07 09:09:16 -04:00
Heyang Zhou
01a761f1d4
chore(ext/kv): limit total key size in an atomic op to 80 KiB (#20395)
Keys are expensive metadata. We track it for various purposes, e.g.
transaction conflict check, and key expiration.

This patch limits the total key size in an atomic operation to 80 KiB
(81920 bytes). This helps ensure efficiency in implementations.
2023-09-07 15:07:04 +08:00
Divy Srivastava
9befa566ec
fix(ext/node): implement AES GCM cipher (#20368)
Adds support for AES-GCM 128/256 bit keys in `node:crypto` and
`setAAD()`, `setAuthTag()` and `getAuthTag()`

Uses https://github.com/littledivy/aead-gcm-stream

Fixes https://github.com/denoland/deno/issues/19836
https://github.com/denoland/deno/issues/20353
2023-09-06 11:01:50 +05:30
zuisong
4a561f12db
fix(node/child_process): don't crash on undefined/null value of an env var (#20378)
Fixes #20373

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-09-05 12:42:35 +02:00
Bartek Iwańczuk
9e243d22f4
Revert "refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' (#20303) (#20370)
This reverts commit
83426be6ee.

Includes a regression test.
2023-09-04 17:05:06 -04:00
Fabian
2cc7c8432f
fix(node): Bump hardcoded version to latest (#20366)
When trying to run
```
deno run -A --unstable npm:astro dev
```
in my Astro project it fails with:
```
Node.js v18.12.1 is not supported by Astro!
Please upgrade Node.js to a supported version: ">=18.14.1"
```
My current version is:
```
~ ❯ node --version
v20.5.1
```

Bumping the version to the latest stable Release of node in
`ext/node/polyfills/_process/process.ts` fixes this.
I don't know if this causes any conflicts, so please feel free to
correct me here.
2023-09-04 12:33:15 +02:00
Igor Zinkovsky
1dc5d42114
fix(ext/kv): add a warning for listenQueue if used with remote KV (#20341) 2023-09-03 17:47:52 -07:00
Bartek Iwańczuk
83426be6ee
refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' (#20303)
Rewrites 3 ops that used "op(deferred)" to use "op2(async(lazy))"
instead.
This will allow us to remove codepath for handling "deferred" ops in
"deno_core".
2023-09-02 08:48:21 +02:00
Bartek Iwańczuk
2b191c6e9d
chore: forward v1.36.4 to main (#20352)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
2023-09-01 18:08:58 +00:00
Bartek Iwańczuk
c9223bc6a5
fix(evt/kv): Add serde feature to uuid (#20350)
`cargo publish` for v1.36.4 failed due to missing `serde` feature on
`uuid` dependency.
2023-09-01 18:41:35 +02:00
Jakub Jirutka
3436f65e20
fix(ext/node): remove unnecessary and incorrect type priority_t (#20276)
`getpriority` and `setpriority` on musl libc accepts `int` / `c_int` /
`i32` as the first argument, not `u32`.

Since the `PRIO_PROCESS` constant is imported from the same crate (libc)
as the `getpriority` and `setpriority` functions, this type cast seems
to be completely unnecessary here.

It was introduced in aa8078b688 by
@crowlKats.

Relevant sources:

-
835661543d/src/unix/linux_like/linux/musl/mod.rs (L739-L740)
- https://git.musl-libc.org/cgit/musl/tree/src/misc/setpriority.c
- https://git.musl-libc.org/cgit/musl/tree/src/misc/getpriority.c

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-09-01 11:21:23 +02:00
Filip Skokan
9d58c896dc
fix(ext/crypto): remove EdDSA alg key checks and export (#20331)
As per https://github.com/WICG/webcrypto-secure-curves/pull/24 this
removes the check for Ed25519 JWK `alg` during importKey and removes the
`alg` for Ed25519 keys during JWK exportKey.
2023-08-31 18:26:26 +05:30
Igor Zinkovsky
441b860978
fix(ext/kv): don't panic if listening on queues and KV is not closed (#20317)
fixes #20312
2023-08-29 11:24:44 -07:00
Bartek Iwańczuk
2929313652
fix(node/http): don't leak resources on destroyed request (#20040)
Closes https://github.com/denoland/deno/issues/19828
2023-08-29 12:13:58 +00:00
Yoshiya Hinosawa
fb7092fb43
fix(ext/node): fix argv[1] in Worker (#20305) 2023-08-29 12:18:25 +09:00
Matt Mastracci
7adaf613bf
fix(ext/node): shared global buffer unlock correctness fix (#20314)
The fix for #20188 was not entirely correct -- we were unlocking the
global buffer incorrectly. This PR introduces a lock state that ensures
we only unlock a lock we have taken out.
2023-08-28 15:28:39 -06:00