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

2002 commits

Author SHA1 Message Date
Asher Gomez
abaffad028
feat: deprecate Deno.Listener.rid (#22076)
For removal in Deno v2.
2024-01-24 18:52:55 +01:00
Asher Gomez
f5097d9d3b
feat: Deno.FsFile.{utime,utimeSync}() and deprecate Deno.{futime,futimeSync} (#22070)
For removal in Deno v2.

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 17:26:49 +01:00
Asher Gomez
62786cfebb
feat: deprecate Deno.close() (#22066)
For removal in Deno v2.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 15:59:55 +01:00
Asher Gomez
4af121687c
feat: deprecate Deno.ftruncate() and Deno.ftruncateSync() (#22069)
For removal in Deno 2.0.
2024-01-24 15:12:22 +01:00
Bartek Iwańczuk
064a6c048a
feat: Add warnings for more deprecated APIs (#21992)
Follow up to https://github.com/denoland/deno/pull/21939 that adds
deprecation warnings to more `Deno` APIs:

- `Deno.copy()`
- `Deno.iter()`
- `Deno.iterSync()`
- `new Deno.Buffer()`
- `Deno.readAll()`
- `Deno.readAllSync()`
- `Deno.writeAll()`
- `Deno.writeAllSync()`
- `Deno.FsWatcher.return`
- `Deno.serveHttp()`
- `Deno.metrics()`

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-24 14:57:54 +01:00
Asher Gomez
aac0ad32bd
feat: deprecate Deno.FsFile constructor and Deno.FsFile.rid (#22072) 2024-01-24 13:36:35 +01:00
Asher Gomez
4c5ce90883
chore: update Deno.{fsync,fsyncSync}() deprecation notices (#22071)
To align with other deprecations.
2024-01-24 09:38:59 +05:30
Asher Gomez
5a4d69354c
feat: deprecate Deno.shutdown() (#22067)
For removal in Deno v2.

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 03:47:48 +01:00
Igor Zinkovsky
46b91eceb1
fix(ext/cron): automatically override unspecified values (#22042)
Fixes #22041
2024-01-24 00:45:11 +00:00
Asher Gomez
47620641e7
feat: FsFile.sync() and FsFile.syncSync() (#22017)
This change:
1. Implements `Deno.FsFile.sync()` and `Deno.FsFile.syncSync()`.
2. Deprecates `Deno.fsync()` and `Deno.fsyncSync()` for removal in Deno
v2, in favour of the above corresponding methods.

Related #21995

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 01:07:06 +01:00
Asher Gomez
2f47ec6c3a
feat: Deno.FsFile.dataSync() and Deno.FsFile.dataSyncSync() (#22019)
This change:
1. Implements `Deno.FsFile.dataSync()` and `Deno.FsFile.dataSyncSync()`.
2. Deprecates `Deno.fdatasync()` and `Deno.fdatasyncSync()` for removal
in Deno v2, in favour of the above corresponding methods.
3. Replaces use of `Deno.fdatasync()` and `Deno.fdatasyncSync()` with
the above instance methods.

Related #21995
2024-01-24 00:31:52 +01:00
Asher Gomez
947ce41e99
feat: deprecate Deno.resources() (#22059)
Most uses of `Deno.resources()` within tests, as they previously checked
for leaked resources. This is not needed as the test runner does this
automatically. Other internal uses of this API have been replaced with
the internal `Deno[Deno.internal].core.resources()`.
2024-01-24 00:27:29 +01:00
Asher Gomez
4eedac3604
feat: Deno.{stdin,stdout,stderr}.isTerminal(), deprecate Deno.isatty() (#22011)
This change:
1. Implements `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` and
`Deno.stderr.isTerminal()`.
2. Deprecates `Deno.isatty()` for removal in Deno v2, in favour of the
above instance methods.
3. Replaces use of `Deno.isatty()` with the above instance methods.

Related #21995

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-24 00:01:56 +01:00
Asher Gomez
18a235e608
refactor: set removal version for Deno.ListenTlsOptions.certFile, Deno.ListenTlsOptions.keyFile and Deno.ConnectTlsOptions.certFile (#22026)
This change:
1. Sets the removal version for `Deno.ListenTlsOptions.certFile`,
`Deno.ListenTlsOptions.keyFile` and `Deno.ConnectTlsOptions.certFile`
for Deno v2, in favour of the `cert`, `key` and `caCerts` options,
respectively.
2. Replaces use of the deprecated options with the new recommended
options.

Towards #22021
2024-01-23 17:35:23 +01:00
Bartek Iwańczuk
427b73c3ec
feat: warn when using --unstable, prefer granular flags (#21452)
This commit deprecates "--unstable" flag. 

When "--unstable" flag is encountered a warning like this is printed:
```
The `--unstable` flag is deprecated, use granular `--unstable-*` flags instead.
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
```
When "--unstable" flag is used and an unstable API is called an
additional warning like this is printed for each API call:
```
The `Deno.dlopen` API was used with `--unstable` flag. The `--unstable` flag is deprecated, use granular `--unstable-ffi` instead. 
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
```
When no "--unstable-*" flag is provided and an unstable API is called
following
warning is issued before exiting:
```
Unstable API 'Deno.dlopen'. The `--unstable-ffi` flag must be provided.
```

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-23 15:33:07 +01:00
Divy Srivastava
ebe4c1421e
chore: use ensureFastOps in 02_surface.js (#22045) 2024-01-23 15:15:40 +01:00
Asher Gomez
d6d437c4dc
BREAKING(unstable): remove Deno.cron() overload (#22035)
This change removes the currently deprecated `Deno.cron()` overload with
`options` as a potential last argument.

This might be fine to do now, in a major release, as `Deno.cron()` is an
unstable API. I thought of doing this while working on #22021. If this
is not ready to remove, I can instead set the removal version of this
overload for Deno v2.

Note: this overload was deprecated in Deno v1.38.2 (#21225). So it's
been deprecated for over 2 months.
2024-01-23 17:37:54 +05:30
Asher Gomez
6238b0a457
refactor: port more ops to ensureFastOps() (#22046) 2024-01-23 17:34:53 +05:30
Bartek Iwańczuk
01b6e38baf
feat: Stabilize Deno.listen for 'unix' transport (#21938) 2024-01-23 17:32:25 +05:30
Yoshiya Hinosawa
2af0c0a3c6
fix(ext/node): fix no arg call of fs.promises.readFile (#22030) 2024-01-23 12:59:39 +09:00
Asher Gomez
6059731594
refactor: set removal version for Deno.Server (#22024)
This change sets the removal version for the deprecated `Deno.Server`
interface for Deno 2.0.

Towards #22021
2024-01-23 02:19:49 +01:00
Bartek Iwańczuk
71551c80a1
feat(unstable): remove Deno.upgradeHttp API (#21856)
Closes https://github.com/denoland/deno/issues/21828.

This API is a huge footgun. And given that "Deno.serveHttp" is a
deprecated API that is discouraged to use (use "Deno.serve()" 
instead); it makes no sense to keep this API around.

This is a step towards fully migrating to Hyper 1.
2024-01-22 21:35:39 +00:00
Leo Kettmeir
8f76762793
feat(web): ImageBitmap (#21898) 2024-01-22 12:08:01 +01:00
Marvin Hagemeister
692738232b
fix(node/fs): promises not exporting fs constants (#21997)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

We were missing the `constants` export in the promise `fs` API which is
available in node.

```ts
import { constants, promises } from "node:fs";
import { constants as fsPromiseConstants } from "node:fs/promises";
console.log(constants === promises.constants); // logs: true
console.log(constants === fsPromiseConstants); // logs: true
```

Fixes https://github.com/denoland/deno/issues/21994
2024-01-21 21:48:48 +01:00
Divy Srivastava
28f64171cb
fix(node): use cppgc for managing X509Certificate (#21999)
Introduces the first cppgc backed Resource into Deno.

This fixes the memory leak when using `X509Certificate`

**Comparison**:

```js
import { X509Certificate } from 'node:crypto';

const r = Deno.readFileSync('cli/tests/node_compat/test/fixtures/keys/agent1-cert.pem');

setInterval(() => {
  for (let i = 0; i < 10000; i++) {
    const cert = new X509Certificate(r);
  }
}, 1000);
```

Memory usage after 5 secs

`main`: 1692MB
`cppgc`: peaks at 400MB
2024-01-20 21:58:37 +05:30
Divy Srivastava
40febd9dd1
feat:: External webgpu surfaces / BYOW (#21835)
This PR contains the implementation of the External webgpu surfaces /
BYOW proposal. BYOW stands for "Bring your own window".

Closes #21713 

Adds `Deno.UnsafeWindowSurface` ( `--unstable-webgpu` API) to the `Deno`
namespace:

```typescript
class UnsafeWindowSurface {
  constructor(
    system: "cocoa" | "x11" | "win32",
    winHandle: Deno.PointerValue,
    displayHandle: Deno.PointerValue | null
  );
  
  getContext(type: "webgpu"): GPUCanvasContext;

  present(): void;
}
```

For the initial pass, I've opted to support the three major windowing
systems. The parameters correspond to the table below:
| system                      | winHandle  | displayHandle |
| -----------------     | ----------   | ------- |
| "cocoa" (macOS)    | `NSView*`       | - |
| "win32" (Windows) | `HWND`         | `HINSTANCE` |
| "x11" (Linux)            | Xlib `Window` | Xlib `Display*` |

Ecosystem support:

- [x] deno_sdl2 (sdl2) -
[mod.ts#L1209](7e177bc652/mod.ts (L1209))
- [x] dwm (glfw) - https://github.com/deno-windowing/dwm/issues/29
- [ ] pane (winit)

<details>
<summary>Example</summary>

```typescript
// A simple clear screen pass, colors based on mouse position.

import { EventType, WindowBuilder } from "https://deno.land/x/sdl2@0.7.0/mod.ts";

const window = new WindowBuilder("sdl2 + deno + webgpu", 640, 480).build();
const [system, windowHandle, displayHandle] = window.rawHandle();

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();

const context = Deno.createWindowSurface(system, windowHandle, displayHandle);

context.configure({
  device: device,
  format: "bgra8unorm",
  height: 480,
  width: 640,
});

let r = 0.0;
let g = 0.0;
let b = 0.0;

for (const event of window.events()) {
  if (event.type === EventType.Quit) {
    break;
  } else if (event.type === EventType.Draw) {
    const textureView = context.getCurrentTexture().createView();

    const renderPassDescriptor: GPURenderPassDescriptor = {
      colorAttachments: [
        {
          view: textureView,
          clearValue: { r, g, b, a: 1.0 },
          loadOp: "clear",
          storeOp: "store",
        },
      ],
    };

    const commandEncoder = device.createCommandEncoder();
    const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
    passEncoder.end();

    device.queue.submit([commandEncoder.finish()]);
    Deno.presentGPUCanvasContext(context);
  }

  if (event.type === EventType.MouseMotion) {
    r = event.x / 640;
    g = event.y / 480;
    b = 1.0 - r - g;
  }
}
```

You can find more examples in the linked tracking issue.

</details>

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-19 22:49:14 +05:30
Divy Srivastava
47232f8a41
fix(node): remove use of non existing FunctionPrototypeApply primordial (#21986)
Fixes #21978
2024-01-19 12:01:46 -05:00
Marvin Hagemeister
59f419bf41
fix(node/http): remoteAddress and remotePort not being set (#21998)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

Ultimately, it came down to using incorrect property names in the
`FakeSocket` constructor. The values are passed under `remoteAddress`,
not `hostname` and `remotePort` instead of `port`.

Fixes https://github.com/denoland/deno/issues/21980
2024-01-19 13:09:37 +01:00
Bartek Iwańczuk
4e3aff8400
chore: upgrade deno_core to 0.247.0 (#21974) 2024-01-18 17:57:22 +01:00
Divy Srivastava
66ff28c21e
fix(node): update req.socket on WS upgrade (#21984)
Update the `req.socket` to be a `net.Socket` from `FakeSocket`

Fixes #21979
2024-01-18 22:24:02 +05:30
Matt Mastracci
971eb0e5e8
chore: bump rustls-tokio-stream and rustls (#21955) 2024-01-16 21:51:54 +01:00
Matt Mastracci
3ff80eb152
chore(ext/cache): remove CachePutResource in preparation for resource rewrite (#21949)
We can use `resourceForReadableStream` to ensure that cached resources
are implemented more efficiently and remove one more resource special
case.
2024-01-15 13:14:54 -07:00
Bartek Iwańczuk
5143b9e7d3
feat(unstable): add Temporal API support (#21738)
This commit adds support for [Stage 3 Temporal API
proposal](https://tc39.es/proposal-temporal/docs/).

The API is available when `--unstable-temporal` flag is passed.

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
2024-01-15 01:26:57 +01:00
Bartek Iwańczuk
fc17ddbcc4
feat: Stabilize Deno.connect for 'unix' transport (#21937) 2024-01-14 21:50:58 +00:00
Bartek Iwańczuk
f3bb0a1a0e
feat: stabilize Deno.connectTls options and Deno.TlsConn.handshake (#21889) 2024-01-14 17:06:26 +00:00
Bartek Iwańczuk
c2127a86cb
feat: stabilize Deno.Conn.ref/unref (#21890) 2024-01-14 17:04:33 +00:00
denobot
248fb9c946
chore: forward v1.39.4 release commit to main (#21933)
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-01-13 20:32:50 -05:00
Bartek Iwańczuk
7471587d29
feat: "rejectionhandled" Web event and "rejectionHandled" Node event (#21875)
This commit adds support for "rejectionhandled" Web Event and
"rejectionHandled" Node event.

```js
import process from "node:process";

process.on("rejectionHandled", (promise) => {
  console.log("rejectionHandled", reason, promise);
});

window.addEventListener("rejectionhandled", (event) => {
  console.log("rejectionhandled", event.reason, event.promise);
});
```

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-12 22:10:42 +00:00
Bartek Iwańczuk
288774c5ed
chore: forward v1.39.3 to main (#21915)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2024-01-12 19:13:18 +00:00
Leo Kettmeir
4122c8f164
fix: add EventSource typings (#21908)
Fixes #21691
2024-01-12 13:28:54 +00:00
Kenta Moriuchi
515a34b4de
refactor: use core.ensureFastOps() (#21888) 2024-01-10 15:37:25 -07:00
cions
881a62869d
fix: android support (#19437)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-10 06:04:14 -07:00
Bartek Iwańczuk
cd43d2b877
chore: upgrade deno_core to 0.244.0 (#21859) 2024-01-09 17:25:10 +01:00
Divy Srivastava
6db631a432
fix(ext/websocket): pass on uncaught errors in idleTimeout (#21846)
Fixes https://github.com/denoland/deno/issues/21840

The problem was hard to reproduce as its a race condition. I've added a
test that reproduces the problem 1/10 tries. We should move the
idleTimeout handling to Rust (maybe even built into fastwebsocket).
2024-01-09 19:56:54 +05:30
Asher Gomez
19c10c0246
chore: cleanup readAll() logic (#21862) 2024-01-09 13:53:28 +01:00
Marvin Hagemeister
040fdeec0b
fix: cjs export rewritten to invalid identifier (#21853)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

Fixes https://github.com/denoland/deno/issues/21836
2024-01-08 17:50:52 +00:00
Asher Gomez
664ffe2ad0
chore(ext/io): cleanup unused functions (#21844)
These functions don't appear to be used anywhere.
2024-01-08 14:04:11 +01:00
Kenta Moriuchi
c2c115ebd8
fix(ext): enable prefer-primordials for internal TypeScript (#21813)
Enabled prefer-primordials lint for ext/cron and ext/kv.
2024-01-07 23:20:02 +01:00
Bartek Iwańczuk
d1706c2ac9
refactor: split runtime/98_global_scope.js (#21785) 2024-01-06 14:40:26 +01:00
Divy Srivastava
bfd5f1598c
feat(ext/crypto): initial support for p521 in generateKey and importKey (#21815)
Part 1 of a potential 3 part series. Ref #13449 

The current implementation passes key material back and forth RustCrypto
group of crates and ring. ring does not implement p521 yet.

This PR adds support for P521 named curve in `generateKey` and
`importKey` where we use RustCrypto. Other parts should be moved over to
the RustGroup group of crates for consistency.
2024-01-06 16:48:31 +05:30
Divy Srivastava
dac9b6ab43
fix(ext/node): add WriteStream.isTTY (#21801) 2024-01-05 22:37:14 +01:00
Kenta Moriuchi
e7e25db24f
chore: update deno_lint for CI (#21802) 2024-01-05 15:03:06 +00:00
Divy Srivastava
9f86705fa6
chore(ext/webgpu): include GPUCanvasContext in snapshot (#21773)
Part 1 of #21713 

Changes:

- Remove `.present()` and add a `presentGPUCanvasContext` (not exposed
yet to users)
- Move lazy load logic to `00_init.js`. This can be used to use webgpu
on-demand from future code (OffScreenCanvas)
2024-01-05 19:55:01 +05:30
Divy Srivastava
611993fbe0
fix(ci): update copright year for _fs_cp.js (#21803) 2024-01-05 13:43:56 +00:00
Divy Srivastava
df062d2c78
fix(ext/node): add fs.cp, fs.cpSync, promises.cp (#21745)
Fixes https://github.com/denoland/deno/issues/20803
Fixes https://github.com/denoland/deno/issues/21723

Performance: copying a 48GiB rust `target` folder (recursive)
| Platform  | `deno` | `node v21.5` | Improvement |
| -------- | ------- | ------- | ------- |
| macOS (APFS) |   3.1secs  |  127.99 secs |  **42x** |
| Windows | 18.3secs | 67.2secs |  **3.8x** |

Copying files with varying sizes:


![image](https://github.com/denoland/deno/assets/34997667/58932652-6f7a-47f5-8504-896dc9ab4ddc)
2024-01-05 18:28:33 +05:30
Bartek Iwańczuk
aadcd64065
chore: forward v1.39.2 release commit to main (#21793) 2024-01-04 23:52:17 +00:00
Kenta Moriuchi
b2cd254c35
fix: strict type check for cross realms (#21669)
Deno v1.39 introduces `vm.runInNewContext`. This may cause problems when
using `Object.prototype.isPrototypeOf` to check built-in types.

```js
import vm from "node:vm";

const err = new Error();
const crossErr = vm.runInNewContext(`new Error()`);

console.assert( !(crossErr instanceof Error) );
console.assert( Object.getPrototypeOf(err) !== Object.getPrototypeOf(crossErr) );
```

This PR changes to check using internal slots solves them.

---

current: 

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error {}
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
Date {}
```

this PR:

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error: message
    at <anonymous>:1:1
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
2018-12-10T02:26:59.002Z
```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-04 09:42:38 +05:30
Divy Srivastava
ad65440092
fix(ext/node): UdpSocket ref and unref (#21777) 2024-01-04 08:51:39 +05:30
Jovi De Croock
f5ad15b504
fix(node/zlib): accept dataview and buffer in zlib bindings (#21756)
Fixes #20516 
Follow up to #21747 and #21746

This tackles the last point of #20516 where certain inputs weren't
accepted in the other zlib methods

This adds the `toU8` conversion of `_brotli` to `_zlib.mjs`, when we
create the ZLibBuffer, we'll sanitize the input. I noticed that the
async had no handler for `string` input so I added that as well.
2024-01-03 19:03:51 +05:30
Divy Srivastava
60403faaf3
fix(ext/node): use node:process in _streams.mjs (#21755)
Fixes https://github.com/denoland/deno/issues/21644

`next build` works:
```
~/gh/deno/target/debug/deno run -A --unstable-byonm ./node_modules/.bin/next build
Warning: Not implemented: process.on("rejectionHandled")
   ▲ Next.js 14.0.4

 ✓ Creating an optimized production build
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
   Collecting page data  ..Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
 ✓ Collecting page data
   Generating static pages (0/5)  [    ]Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
Warning: Not implemented: process.on("rejectionHandled")
 ✓ Generating static pages (5/5)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    5.32 kB        87.4 kB
└ ○ /_not-found                          875 B            83 kB
+ First Load JS shared by all            82.1 kB
  ├ chunks/938-5e061ba0d46125b1.js       26.8 kB
  ├ chunks/fd9d1056-735d320b4b8745cb.js  53.5 kB
  ├ chunks/main-app-2945f337109ea73c.js  220 B
  └ chunks/webpack-e3c6517d4ab8d680.js   1.68 kB


○  (Static)  prerendered as static content
```
2024-01-02 19:08:05 +01:00
Divy Srivastava
9f7586a206
fix(ext/node): implement os.machine (#21751) 2024-01-02 14:57:54 +01:00
Divy Srivastava
8e4feacd25
fix(ext/http): use arraybuffer binaryType for server websocket (#21741)
Ref
https://github.com/denoland/deno/issues/15340#issuecomment-1872353134
2024-01-02 10:30:09 +05:30
Divy Srivastava
642c4a44a5
fix(ext/node): querystring stringify without encode callback (#21740)
Fixes https://github.com/denoland/deno/issues/21734

Changes:
- Use default encode when options do not provide a encode callback.
- Remove internal TS for `node:querystring`. Its not helping catching
bugs like this because of invalid type assumptions and use of `any`,
more of a maintenance burden.
2024-01-02 04:54:11 +00:00
林炳权
96b581bdd2
chore: update to Rust 1.75 (#21731) 2024-01-01 23:22:48 +01:00
David Sherret
7e72f3af61
chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
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
Matt Mastracci
9198bbd454
fix(ext/http): don't panic on stream responses in cancelled requests (#20316)
When a TCP connection is force-closed (ie: browser refresh), the
underlying future we pass to Hyper is dropped which may cause us to try
to drop the body resource while the OpState lock is still held.

Preconditions for this bug to trigger:

 - The body resource must have been taken
- The response must return a resource (which requires us to take the
OpState lock)
 - The TCP connection must have been dropped before this

Fixes #20315 and #20298
2023-08-28 13:29:34 -06:00
osddeitf
c2547ba039
fix(node/http): correctly send Content-length header instead of Transfer-Encoding: chunked (#20127)
Fix #20063.
2023-08-28 09:32:54 +02:00
Jonathan Rezende
d22a6663fa
fix(network): adjust Listener type params (#18642)
Fixes https://github.com/denoland/deno/issues/18635
2023-08-27 20:55:04 +00:00
林炳权
2080669943
chore: update to Rust 1.72 (#20258)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

As the title.

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-26 22:04:12 -06:00
Igor Zinkovsky
e4cebf3e0d
fix(kv) increase number of allowed mutations in atomic (#20126)
fixes #19741

Impose a limit on the total atomic payload size
2023-08-26 18:26:09 -07:00
Divy Srivastava
1cb547d885
fix(node): propagate create cipher errors (#20280)
Fixes https://github.com/denoland/deno/issues/19002
2023-08-26 10:45:37 +05:30
Matt Mastracci
8bb4e10881
fix(ext/tls): upgrade webpki version (#20285)
This removes a webpki version that was showing up as vulnerable to
https://github.com/briansmith/webpki/issues/69.

Needed to upgrade `reqwest` as part of this.
2023-08-25 23:40:25 +02:00
VlkrS
37de5e8623
feat(node): use i32 for priority_t on MacOS and {Free,Open}BSD (#20286)
Reference from the FreeBSD port

3afa24c6e3/www/deno/files/patch-ext_node_ops_os.rs
2023-08-25 16:46:19 +00:00
denobot
3a2d284c96
chore: forward v1.36.3 release commit to main (#20270)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-24 17:53:01 +00:00
Matt Mastracci
b1ce2e4167
fix(ext/web): add stream tests to detect v8slice split bug (#20253)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-23 17:03:05 -06:00
Matt Mastracci
9b01307704
fix(ext/web): better handling of errors in resourceForReadableStream (#20238)
Improves error handling when the Resource is closed in various phases of
the ReadableStream. Ensure that we send a consistent `cancel` reason.
2023-08-22 16:16:34 -06:00
Matt Mastracci
c37b9655b6
fix(ext/node): simultaneous reads can leak into each other (#20223)
Reported in #20188

This was caused by re-use of a global buffer `BUF` during simultaneous
async reads.
2023-08-22 14:45:10 +00:00
Heyang Zhou
6d4a005e41
feat(ext/kv): connect to remote database (#20178)
This patch adds a `remote` backend for `ext/kv`. This supports
connection to Deno Deploy and potentially other services compatible with
the KV Connect protocol.
2023-08-22 13:56:00 +08:00
David Sherret
5834d282d4
refactor: upgrade deno_ast 0.28 and deno_semver 0.4 (#20193) 2023-08-21 09:53:52 +00:00
Matt Mastracci
576d0db372
fix(ext/http): ensure request body resource lives as long as response is alive (#20206)
Deno.serve's fast streaming implementation was not keeping the request
body resource ID alive. We were taking the `Rc<Resource>` from the
resource table during the response, so a hairpin duplex response that
fed back the request body would work.

However, if any JS code attempted to read from the request body (which
requires the resource ID to be valid), the response would fail with a
difficult-to-diagnose "EOF" error.

This was affecting more complex duplex uses of `Deno.fetch` (though as
far as I can tell was unreported).

Simple test:

```ts
        const reader = request.body.getReader();
        return new Response(
          new ReadableStream({
            async pull(controller) {
              const { done, value } = await reader.read();
              if (done) {
                controller.close();
              } else {
                controller.enqueue(value);
              }
            },
          }),
```

And then attempt to use the stream in duplex mode:

```ts

async function testDuplex(
  reader: ReadableStreamDefaultReader<Uint8Array>,
  writable: WritableStreamDefaultWriter<Uint8Array>,
) {
  await writable.write(new Uint8Array([1]));
  const chunk1 = await reader.read();
  assert(!chunk1.done);
  assertEquals(chunk1.value, new Uint8Array([1]));
  await writable.write(new Uint8Array([2]));
  const chunk2 = await reader.read();
  assert(!chunk2.done);
  assertEquals(chunk2.value, new Uint8Array([2]));
  await writable.close();
  const chunk3 = await reader.read();
  assert(chunk3.done);
}
```

In older versions of Deno, this would just lock up. I believe after
23ff0e722e, it started throwing a more
explicit error:

```
httpServerStreamDuplexJavascript => ./cli/tests/unit/serve_test.ts:1339:6
error: TypeError: request or response body error: error reading a body from connection: Connection reset by peer (os error 54)
    at async Object.pull (ext:deno_web/06_streams.js:810:27)
```
2023-08-21 01:35:26 +00:00
Bartek Iwańczuk
32bbba3db2
perf(ext/event): always set timeStamp to 0 (#20191)
```js
Deno.bench(function eventNew() {
  new Event("foo");
});
```

<b>main</b>
```
./target/release/deno bench event_bench.js
cpu: Apple M1 Max
runtime: deno 1.36.1 (aarch64-apple-darwin)

file:///Users/ib/dev/deno/event_bench.js
benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------
eventNew       36.43 ns/iter  27,451,874.9   (35.15 ns … 46.98 ns)  37.68 ns   40.7 ns  41.69 ns

```

<b>this PR</b>
```
./target/release/deno bench event_bench.js
cpu: Apple M1 Max
runtime: deno 1.36.1 (aarch64-apple-darwin)

file:///Users/ib/dev/deno/event_bench.js
benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------
eventNew       13.71 ns/iter  72,958,970.0   (12.85 ns … 31.79 ns)  15.11 ns  16.49 ns   17.5 ns

```

Towards #20167
2023-08-20 10:02:47 +00:00
Marcos Casagrande
7847de0974
perf(ext/event): optimize addEventListener options converter (#20203)
This PR optimizes `addEventListener` by replacing
`webidl.createDictionaryConverter("AddEventListenerOptions", ...)` with
a custom options parsing function to avoid the overhead of `webidl`
methods

**this PR**

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

benchmark                                           time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------------------------------------- -----------------------------
addEventListener options converter (undefined)       4.87 ns/iter 205,248,660.8     (4.7 ns … 13.18 ns)   4.91 ns    5.4 ns    5.6 ns
addEventListener options converter (signal)         13.02 ns/iter  76,782,031.2   (11.74 ns … 18.84 ns)  13.08 ns  16.22 ns  16.57 ns
```

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

benchmark                                           time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------------------------------------- -----------------------------
addEventListener options converter (undefined)     108.36 ns/iter   9,228,688.6  (103.5 ns … 129.88 ns) 109.69 ns 115.61 ns 125.28 ns
addEventListener options converter (signal)        134.03 ns/iter   7,460,878.1 (129.14 ns … 144.54 ns) 135.68 ns 141.13 ns  144.1 ns
```

```js
const tg = new EventTarget();
const signal = new AbortController().signal;

Deno.bench("addEventListener options converter (undefined)", () => {
  tg.addEventListener("foo", null); // null callback to only bench options converter
});

Deno.bench("addEventListener options converter (signal)", () => {
  tg.addEventListener("foo", null, { signal });
});
```

Towards https://github.com/denoland/deno/issues/20167
2023-08-20 11:30:57 +02:00
Marcos Casagrande
e1aa514179
perf(ext/event): replace ReflectHas with object lookup (#20190)
This PR optimizes event dispatch by replacing `ReflectHas` with object
lookup. I also made `isSlottable` return `false` since AFAIK there
aren't any slottables nodes in Deno

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

benchmark            time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------------- -----------------------------
event dispatch       80.46 ns/iter  12,428,739.4  (73.84 ns … 120.07 ns)  81.82 ns  86.34 ns  91.18 ns
```

**main**

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

benchmark            time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------------- -----------------------------
event dispatch      102.66 ns/iter   9,741,319.6  (96.66 ns … 132.88 ns) 104.18 ns 114.58 ns 118.45 ns
```

```js
const tg = new EventTarget();
const ev = new Event("foo");

const listener = () => {};
tg.addEventListener("foo", listener);

Deno.bench("event dispatch ", () => {
  tg.dispatchEvent(ev);
});
```

towards https://github.com/denoland/deno/issues/20167
2023-08-18 14:44:57 +02:00
Bartek Iwańczuk
a48ec1d563
fix(node/http): emit error when addr in use (#20200)
Closes https://github.com/denoland/deno/issues/20186
2023-08-18 13:48:18 +02:00
Heyang Zhou
c77c836a23
feat(ext/kv): key expiration (#20091)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-08-18 17:34:16 +08:00
David Sherret
4535f79a4a
fix(npm): do not panic providing file url to require.resolve paths (#20182)
Closes #19922
2023-08-17 10:39:06 -04:00
Matt Mastracci
23ff0e722e
feat(ext/web): resourceForReadableStream (#20180)
Extracted from fast streams work.

This is a resource wrapper for `ReadableStream`, allowing us to treat
all `ReadableStream` instances as resources, and remove special paths in
both `fetch` and `serve`.

Performance with a ReadableStream response yields ~18% improvement:

```
  return new Response(new ReadableStream({
    start(controller) {
      controller.enqueue(new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]));
      controller.close();
    }
  })
```

This patch:

```
12:36 $ third_party/prebuilt/mac/wrk http://localhost:8080
Running 10s test @ http://localhost:8080
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    99.96us  100.03us   6.65ms   98.84%
    Req/Sec    47.73k     2.43k   51.02k    89.11%
  959308 requests in 10.10s, 117.10MB read
Requests/sec:  94978.71
Transfer/sec:     11.59MB
```

main:

```
Running 10s test @ http://localhost:8080
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   163.03us  685.51us  19.73ms   99.27%
    Req/Sec    39.50k     3.98k   66.11k    95.52%
  789582 requests in 10.10s, 82.83MB read
Requests/sec:  78182.65
Transfer/sec:      8.20MB
```
2023-08-17 07:52:37 -06:00
Heyang Zhou
0960e895da
fix(ext/kv): retry transaction on SQLITE_BUSY errors (#20189)
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes https://github.com/denoland/deno/issues/20116.
2023-08-17 18:53:55 +08:00
Marcos Casagrande
ec63b36994
perf(ext/event): optimize Event constructor (#20181)
This PR optimizes `Event` constructor

- ~Added a fast path for empty `eventInitDict`~ Removed `EventInit`
dictionary converter
- Don't make `isTrusted` a
[LegacyUnforgeable](https://webidl.spec.whatwg.org/#LegacyUnforgeable)
property. Doing so makes it non-spec compliant but calling
`Object/Reflect.defineProperty` on the constructor is a big bottleneck.
Node did the same a few months ago
https://github.com/nodejs/node/pull/46974. In my opinion, the
performance gains are worth deviating from the spec for a
browser-related property.

**This PR**

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

benchmark                      time (avg)        iter/s             (min … max)       p75       p99      p995
------------------------------------------------------------------------------- -----------------------------
event constructor no init      36.69 ns/iter  27,257,504.6   (33.36 ns … 42.45 ns)  37.71 ns  39.61 ns  40.07 ns
event constructor               36.7 ns/iter  27,246,776.6   (33.35 ns … 56.03 ns)  37.73 ns  40.14 ns  41.74 ns
```

**main**

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

benchmark                      time (avg)        iter/s             (min … max)       p75       p99      p995
------------------------------------------------------------------------------- -----------------------------
event constructor no init     380.48 ns/iter   2,628,275.8 (366.66 ns … 399.39 ns) 384.58 ns 398.27 ns 399.39 ns
event constructor             480.33 ns/iter   2,081,882.6 (466.67 ns … 503.47 ns) 484.27 ns 501.28 ns 503.47 ns
```

```js
Deno.bench("event constructor no init", () => {
  const event = new Event("foo");
});

Deno.bench("event constructor", () => {
  const event = new Event("foo", { bubbles: true, cancelable: false });
});
```

towards https://github.com/denoland/deno/issues/20167
2023-08-17 10:35:18 +02:00
Leo Kettmeir
1b0e394d48
fix: release ReadeableStream in fetch (#17365)
Fixes #16648

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-08-16 14:02:15 +02:00
Marcos Casagrande
838140fb82
perf(ext/urlpattern): optimize URLPattern.exec (#20170)
This PR optimizes `URLPattern.exec` 

- Use component keys from constructor instead of calling it on every
`.exec`. AFAIK keys should always be
`protocol`,`username`,`password`,`hostname`,`port`,`pathname`,`search`,`hash`.
Haven't looked much into it but I think it's safe to define these
outside the constructor as well.
- Add a fast path for `/^$/u` (default regexp) and empty input
- Replaced `ArrayPrototypeMap` & `ObjectFromEntries` with a `for` loop.


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

benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------
exec 1          2.17 µs/iter     461,022.8     (2.14 µs … 2.27 µs)   2.18 µs   2.27 µs   2.27 µs
exec 2          4.13 µs/iter     242,173.4     (4.08 µs … 4.27 µs)   4.15 µs   4.27 µs   4.27 µs
exec 3          2.55 µs/iter     391,508.1     (2.53 µs … 2.68 µs)   2.56 µs   2.68 µs   2.68 µs
```

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

benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------
exec 1          2.45 µs/iter     408,092.4     (2.41 µs … 2.55 µs)   2.46 µs   2.55 µs   2.55 µs
exec 2          4.41 µs/iter     226,706.0   (3.49 µs … 399.56 µs)   4.39 µs   5.49 µs   6.07 µs
exec 3          2.99 µs/iter     334,833.4     (2.94 µs … 3.21 µs)   2.99 µs   3.21 µs   3.21 µs
```
2023-08-16 12:58:03 +02:00
Evan
79d1445796
fix(ext/node): allow for the reassignment of userInfo() on Windows (#20165)
The goal of this PR is to address issue #20106 where a `TypeError`
occurs when the variables `uid` and `gid` from `userInfo()` in `node:os`
are reassigned if the user is on Windows. Both `uid` and `gid` are
marked as `const` therefore producing a `TypeError` when the two are
reassigned.

This PR achieves that goal by marking `uid` and `gid` as `let`
2023-08-16 11:28:49 +02:00
Matt Mastracci
4380a09a05
feat(ext/node): eagerly bootstrap node (#20153)
To fix bugs around detection of when node emulation is required, we will
just eagerly initialize it. The improvements we make to reduce the
impact of the startup time:

 - [x] Process stdin/stdout/stderr are lazily created
 - [x] node.js global proxy no longer allocates on each access check
- [x] Process checks for `beforeExit` listeners before doing expensive
shutdown work
- [x] Process should avoid adding global event handlers until listeners
are added

Benchmarking this PR (`89de7e1ff`) vs main (`41cad2179`)

```
12:36 $ third_party/prebuilt/mac/hyperfine --warmup 100 -S none './deno-41cad2179 run ./empty.js' './deno-89de7e1ff run ./empty.js'
Benchmark 1: ./deno-41cad2179 run ./empty.js
  Time (mean ± σ):      24.3 ms ±   1.6 ms    [User: 16.2 ms, System: 6.0 ms]
  Range (min … max):    21.1 ms …  29.1 ms    115 runs
 
Benchmark 2: ./deno-89de7e1ff run ./empty.js
  Time (mean ± σ):      24.0 ms ±   1.4 ms    [User: 16.3 ms, System: 5.6 ms]
  Range (min … max):    21.3 ms …  28.6 ms    126 runs
```

Fixes https://github.com/denoland/deno/issues/20142
Fixes https://github.com/denoland/deno/issues/15826
Fixes https://github.com/denoland/deno/issues/20028
2023-08-16 04:36:36 +09:00
Marcos Casagrande
ddbb5fdfb0
perf(ext/node): optimize http headers (#20163)
This PR optimizes Node's `IncomingMessageForServer.headers` by replacing
`Object.fromEntries()` with a loop and `headers.entries` with
`headersEntries` which returns the internal array directly instead of an
iterator

## Benchmarks

Using `wrk` with 5 headers

```
wrk -d 10s --latency -H "X-Deno: true" -H "Accept: application/json" -H "X-Foo: bar" -H "User-Agent: wrk" -H "Accept-Encoding: gzip, br" http://127.0.0.1:3000
```

**this PR**

```
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   167.53us  136.89us   2.75ms   97.33%
    Req/Sec    31.98k     1.38k   36.39k    70.30%
  Latency Distribution
     50%  134.00us
     75%  191.00us
     90%  234.00us
     99%  544.00us
  642548 requests in 10.10s, 45.96MB read
Requests/sec:  63620.36
Transfer/sec:      4.55MB
```

**main**

```
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   181.31us  132.54us   3.79ms   97.13%
    Req/Sec    29.21k     1.45k   32.93k    79.21%
  Latency Distribution
     50%  148.00us
     75%  198.00us
     90%  261.00us
     99%  545.00us
  586939 requests in 10.10s, 41.98MB read
Requests/sec:  58114.01
Transfer/sec:      4.16MB
```

```js
import express from "npm:express";

const app = express();
app.get("/", function (req, res) {
  req.headers;
  res.end();
});
app.listen(3000);
```
2023-08-15 16:59:35 +02:00
Marcos Casagrande
0fc31d9d65
fix(ext/fetch): clone second branch chunks in Body.clone() (#20057)
This PR makes `Body.clone()` spec compliant:
https://fetch.spec.whatwg.org/#concept-body-clone

> 1, Let « out1, out2 » be the result of
[teeing](https://streams.spec.whatwg.org/#readablestream-tee) body’s
[stream](https://fetch.spec.whatwg.org/#concept-body-stream).
> ...
> To tee a
[ReadableStream](https://streams.spec.whatwg.org/#readablestream)
stream, return ?
[ReadableStreamTee](https://streams.spec.whatwg.org/#readable-stream-tee)(stream,
true).

---
Closes #10994
2023-08-15 09:21:02 +02:00
Bartek Iwańczuk
119526a7a5
fix(require): use canonicalized path for loading content (#20133) 2023-08-15 09:10:54 +02:00
Evan
ece2a3de5b
fix(ext/net): implement a graceful error on an invalid SSL certificate (#20157)
The goal of this PR is to address issue #19520 where Deno panics when
encountering an invalid SSL certificate.

This PR achieves that goal by removing an `.expect()` statement and
implementing a match statement on `tsl_config` (found in
[/ext/net/ops_tsl.rs](e071382768/ext/net/ops_tls.rs (L1058)))
to check whether the desired configuration is valid

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-15 00:11:12 +00:00
Marcos Casagrande
625bd39050
perf(ext/headers): optimize headers iterable (#20155)
This PR makes more optimizations to headers iterable by removing
`ObjectEntries` which was consistently prominent in the flame graph when
benchmarking an express server.

**this PR**

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

benchmark         time (avg)        iter/s             (min … max)       p75       p99      p995
------------------------------------------------------------------ -----------------------------
headers iter        9.6 µs/iter     104,134.1   (8.74 µs … 131.31 µs)   9.47 µs  12.61 µs  17.81 µs
```

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

benchmark         time (avg)        iter/s             (min … max)       p75       p99      p995
------------------------------------------------------------------ -----------------------------
headers iter      12.87 µs/iter      77,675.9  (11.97 µs … 132.34 µs)  12.76 µs  16.49 µs   26.4 µs
```


```js
const headers = new Headers({
  "Content-Type": "application/json",
  "X-Content-Type": "application/json",
  "Date": "Thu, 14 Aug 2023 17:45:10 GMT",
  "X-Deno": "Deno",
  "Powered-By": "Deno",
  "Content-Encoding": "gzip",
  "Set-Cookie": "__Secure-ID=123; Secure; Domain=example.com",
  "Content-Length": "150",
  "Vary": "Accept-Encoding, Accept, X-Requested-With",
});

Deno.bench('headers iter', () => {
  [...headers]
})
```
2023-08-14 19:13:55 +00:00
Marcos Casagrande
e071382768
perf(ext/node): cache IncomingMessageForServer.headers (#20147)
This PR adds caching to node's `req.headers`

```js
import express from "npm:express";
const app = express();

app.get("/", function (req, res) {
  const ua = req.header("User-Agent");
  const auth = req.header("Authorization");
  const type = req.header("Content-Type");
  const ip = req.header("X-Forwarded-For");
  res.end();
});

app.listen(3000);
```

**this PR**
```
wrk -d 10s --latency http://127.0.0.1:3000
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   155.64us  152.14us   5.74ms   97.39%
    Req/Sec    35.00k     1.97k   39.10k    80.69%
  Latency Distribution
     50%  123.00us
     75%  172.00us
     90%  214.00us
     99%  563.00us
  703420 requests in 10.10s, 50.31MB read
Requests/sec:  69648.45
Transfer/sec:      4.98MB
```

**main**
```
wrk -d 10s --latency http://127.0.0.1:3000
Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   217.95us  786.89us  26.26ms   98.23%
    Req/Sec    32.32k     2.54k   37.19k    87.13%
  Latency Distribution
     50%  130.00us
     75%  191.00us
     90%  232.00us
     99%    1.88ms
  649411 requests in 10.10s, 46.45MB read
Requests/sec:  64300.44
Transfer/sec:      4.60MB
```
2023-08-14 15:14:02 +02:00
Matt Mastracci
babfba14ef
chore: deno_core -> 0.201.0 (#20135) 2023-08-12 19:04:45 +00:00