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

1373 commits

Author SHA1 Message Date
Bartek Iwańczuk
1edc8693bf
chore: upgrade deno_core and rusty_v8 (#19773) 2023-07-09 22:48:47 +00:00
David Sherret
f3095b8d31
chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
Divy Srivastava
e4870d84be
perf(ext/node): native vectored write for server streams (#19752)
```
# main
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 106182.250000
Msg/sec: 110279.750000
^C

# this PR
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 131632.250000
Msg/sec: 134754.250000
^C
```
2023-07-07 22:17:08 +05:30
Matt Mastracci
7d022ad11a
fix(ext/http): Use brotli compression params (#19758)
Fixes #19737 by adding brotli compression parameters.

Time after:

`Accept-Encoding: gzip`:

```
real    0m0.214s
user    0m0.005s
sys     0m0.013s
```

`Accept-Encoding: br`:

Before:

```
real    0m10.303s
user    0m0.005s
sys     0m0.010s
```

After:

```
real    0m0.127s
user    0m0.006s
sys     0m0.014s
```
2023-07-07 10:46:56 -06:00
Divy Srivastava
75d2c045f7
perf(ext/websocket): optimize server websocket js (#19719)
Split from https://github.com/denoland/deno/pull/19686

- timestamp set to 0 for server websocket events.
- take fast call path with op_ws_send_binary.
2023-07-07 09:09:25 +05:30
Bartek Iwańczuk
106e1bd90e
fix: remove unstable check for Deno.listenTls#alpnProtocols (#19732) 2023-07-06 13:45:15 +00:00
Bartek Iwańczuk
de630b9b78
perf(node/async_hooks): optimize AsyncLocalStorage (#19729)
This makes the implementation of "AsyncLocalStorage" from
"node:async_hooks" 3.5x faster than before for noop benchmark
(measuring baseline overhead). It's still 3.5x slower than not
using `AsyncLocalStorage` and 1.64x slower than using
noop promise hooks.
2023-07-06 13:05:10 +02:00
Divy Srivastava
57fae55d82
perf(ext/node): optimize net streams (#19678)
~4.5x improvement in `npm:ws` echo benchmark:

```
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 101083.750000
Msg/sec: 103606.000000
^C

$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 24906.750000
Msg/sec: 28478.000000
^C
```
2023-07-05 22:45:10 +05:30
denobot
1ac5fddf54
1.35.0 (#19717)
Bumped versions for 1.35.0

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-05 01:58:01 +02:00
await-ovo
686ec85f52
fix(ext/node): Define performance.timeOrigin as getter property (#19714) 2023-07-04 20:19:18 +03:00
Bartek Iwańczuk
39872646eb
feat: stabilize 'alpnProtocols' setting (#19704)
Ref https://github.com/denoland/deno/issues/19685
2023-07-04 15:28:50 +02:00
Bartek Iwańczuk
3c8bbc434d
feat: Stabilize Deno.serve() API (#19141)
This commit stabilizes "Deno.serve()", which becomes the
preferred way to create HTTP servers in Deno.

Documentation was adjusted for each overload of "Deno.serve()"
API and the API always binds to "127.0.0.1:8000" by default.
2023-07-04 01:46:32 +02:00
await-ovo
208e65d33a
fix(npm): escape export identifier in double quoted string (#19694) 2023-07-03 18:41:09 +00:00
ud2
d632cce129
fix(dts): make globals available on globalThis (#19438)
This PR changes Web IDL interfaces to be declared with `var` instead of
`class`, so that accessing them via `globalThis` does not raise type
errors.

Closes #13390.
2023-07-03 14:36:55 -04:00
Matt Mastracci
2c2e6adae8
fix(ext/http): Catch errors in eager stream timeout to avoid uncaught promise rejections (#19691)
Fixes #19687 by adding a rejection handler to the write inside the
setTimeout. There is a small window where the promise is actually not
awaited and may reject without a handler.
2023-07-03 15:30:02 +00:00
await-ovo
0f4051a37a
fix(ext/node): ignore cancelled timer when node timer refresh (#19637)
For timers that have already executed clearTimeout, there is no need to recreate a new timer when refresh is executed again.
2023-07-02 19:11:34 +00:00
Bartek Iwańczuk
01f0d03ae8
refactor: rename built-in node modules from ext:deno_node/ to node: (#19680)
Closes https://github.com/denoland/deno/issues/19510
2023-07-02 20:19:30 +02:00
Leo Kettmeir
805497a9a5
feat: ReadableStream.from (#19446)
Closes #19417
2023-07-02 19:30:05 +02:00
Lino Le Van
17ddf2f97c
feat(ext/url): URLSearchParams two-argument delete() and has() (#19654) 2023-07-02 17:26:48 +02:00
Luca Casonato
d8e8e60f9f
feat(ext/fetch): add Headers#getSetCookie (#13542)
Spec change: https://github.com/whatwg/fetch/pull/1346
Tests: https://github.com/web-platform-tests/wpt/pull/31442 (ran against
this PR and they all pass)

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-02 13:20:56 +02:00
David Sherret
3b9845d891
fix(npm): handle more reserved words as cjs exports (#19672)
Closes #19665
2023-07-01 21:43:17 -04:00
Nayeem Rahman
b9c0e7cd55
Reland "fix(cli): don't store blob and data urls in the module cache" (#18581)
Relands #18261 now that
https://github.com/lucacasonato/esbuild_deno_loader/pull/54 is landed
and used by fresh.
Fixes #18260.
2023-07-02 00:52:30 +02:00
Luca Casonato
476e4ed03c
fix(ext/kv): expose Deno.AtomicOperation (#19674) 2023-07-01 09:24:15 +02:00
Leo Kettmeir
4db534d461
fix(node/http): add setKeepAlive to FakeSocket (#19659)
Closes #19535
2023-06-30 03:39:16 +02:00
Matt Mastracci
13a45ae994
chore: upgrade Rust to 1.70 and libffi-sys to 2.3.0 (#19639)
Bump:

 - Rust -> 1.7.0
 - libffi-sys -> 2.3.0

LLVM version won't change often, but it's slightly easier to edit now.
2023-06-29 15:25:48 -06:00
Matt Mastracci
fbb6932934
refactor(ops): op2 support for generics (#19636)
Implementation of generics for `#[op2]`, along with some refactoring to
improve the ergonomics of ops with generics parameters:

- The ops have generics on the struct rather than the associated
methods, which allows us to trait-ify ops (impossible when they are on
the methods)
- The decl() method can become a trait-associated const field which
unlocks future optimizations

Callers of ops need to switch from:
`op_net_connect_tcp::call::<TestPermission>(conn_state, ip_addr)` to
`op_net_connect_tcp::<TestPermission>::call(conn_state, ip_addr)`.
2023-06-29 10:23:14 -06:00
Matt Mastracci
93b3ff0170
fix(ext/websocket): Ensure that errors are available after async response returns (#19642)
Fixes the WPT tests that test w/invalid codes. Also explicitly ignoring
some h2 tests to hopefully prevent flakes.

The previous changes to WebSocketStream introduced a bug where the close
errors were not made available if the `pull` method was re-entrant.
2023-06-29 07:24:01 -06:00
Nicholas Berlette
b6253370cc
fix(console): correct the parseCssColor algorithm (#19645)
This is a fix for issue #19644, concerning the `parseCssColor` function
in the file `ext/console/01_console.js`. Changes made on lines
2756-2758. To sum it up:

> The internal `parseCssColor` function currently parses 3/4-digit hex
colors incorrectly. For example, it parses the string `#FFFFFF` as
`[255, 255, 255]` (as expected), but returns `[240, 240, 240]` for
`#FFF`, when it should return the same triplet as the former.

While it's not going to cause a fatal runtime error, it did bug me
enough to fix it real quick.
2023-06-28 19:46:30 -06:00
Leo Kettmeir
558eb9f132
fix(console): add assert function (#19635) 2023-06-28 17:29:16 +02:00
Bartek Iwańczuk
f372688f22
fix: lint on main branch (#19622) 2023-06-27 17:35:19 +09:00
Kenta Moriuchi
e16b74d792
chore(ext/node): disable prefer-primordials on a per-file basis (#19553) 2023-06-27 15:18:22 +09:00
Felipe Baltor
814edcdd57
test(ext/node): port crypto_test.ts from deno_std (#19561) 2023-06-27 11:04:49 +09:00
Martin Fischer
801b9ec62d
chore: fix typos (#19572) 2023-06-26 09:10:27 -04:00
Bartek Iwańczuk
ad3c494b46
Revert "Reland "refactor(core): cleanup feature flags for js source i… (#19611)
…nclusion" (#19519)"

This reverts commit 28a4f3d0f5.

This change causes failures when used outside Deno repo:
```
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.34.3+b37b286
Args: ["/opt/hostedtoolcache/deno/0.0.0-b37b286f7fa68d5656f7c180f6127bdc38cf2cf5/x64/deno", "test", "--doc", "--unstable", "--allow-all", "--coverage=./cov"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to read "/home/runner/work/deno/deno/core/00_primordials.js"

Caused by:
    No such file or directory (os error 2)', core/runtime/jsruntime.rs:699:8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2023-06-26 13:54:10 +02:00
Ryan Clements
b37b286f7f
fix(ext/node): remove path.toFileUrl (#19536) 2023-06-26 13:08:17 +09:00
Nayeem Rahman
28a4f3d0f5
Reland "refactor(core): cleanup feature flags for js source inclusion" (#19519)
Relands #19463. This time the `ExtensionFileSourceCode` enum is
preserved, so this effectively just splits feature
`include_js_for_snapshotting` into `exclude_js_sources` and
`runtime_js_sources`, adds a `force_include_js_sources` option on
`extension!()`, and unifies `ext::Init_ops_and_esm()` and
`ext::init_ops()` into `ext::init()`.
2023-06-25 09:35:31 +02:00
Divy Srivastava
4a18c76135
fix(ext/node): support brotli APIs (#19223)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-24 19:42:08 +05:30
Matt Mastracci
65d9bfb533
refactor(ops): Adding op2 macro and implementing in a couple of places (#19534)
This is a new op system that will eventually replace `#[op]`. 

Features
 - More maintainable, generally less-coupled code
 - More modern Rust proc-macro libraries
- Enforces correct `fast` labelling for fast ops, allowing for visual
scanning of fast ops
 - Explicit marking of `#[string]`, `#[serde]` and `#[smi]` parameters.

This first version of op2 supports integer and Option<integer>
parameters only, and allows us to start working on converting ops and
adding features.
2023-06-24 13:54:10 +02:00
Martin Fischer
8d6dbda90e
chore(ext/web): align with whatwg/dom typo fix (#19584)
The WHATWG DOM specification has corrected the spelling of "slotable" to
"slottable".[1] This commit aligns our implementation accordingly.

[1]: https://github.com/whatwg/dom/pull/845
2023-06-24 12:20:14 +02:00
Divy Srivastava
f81027ae9f
fix(serde_v8): Do not coerce values in serde_v8 (#19569)
Fixes #19568 

Values are not coerced to the desired type during deserialisation. This
makes serde_v8 stricter.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-23 12:52:48 +02:00
Luca Bruno
76f85a783e
fix(ext/fs): fix boolean checks in JS parser (#19586)
This fixes a bug in file metadata parsing logic, which now properly
evaluates boolean fields when forwarding for atime / mtime / birthtime
values.

Ref: https://github.com/denoland/deploy_feedback/issues/409
2023-06-23 08:07:03 +02:00
Bartek Iwańczuk
dda0f1c343
refactor(serde_v8): split ZeroCopyBuf into JsBuffer and ToJsBuffer (#19566)
`ZeroCopyBuf` was convenient to use, but sometimes it did hide details
that some copies were necessary in certain cases. Also it made it way to easy
for the caller to pass around and convert into different values. This commit
splits `ZeroCopyBuf` into `JsBuffer` (an array buffer coming from V8) and
`ToJsBuffer` (a Rust buffer that will be converted into a V8 array buffer).

As a result some magical conversions were removed (they were never used)
limiting the API surface and preparing for changes in #19534.
2023-06-22 23:37:56 +02:00
David Sherret
1301a03b51
refactor(npm): remove needless resolve_nv_ref_from_pkg_req_ref on NpmResolver (#19582) 2023-06-22 11:50:48 +02:00
Santhanam
52da60ed53
fix(deno/ext): Fix WebCrypto API's deriveKey (#19545)
Fixes a bug I noticed when deriving a key based from `ECDH`. Similar
issue is also mentioned in #14693, where they derive a key using
`PBKDF2`

- In the WebCrypto API, `deriveKey()` is equivalent to `deriveBits()`
followed by `importKey()`
- But, `deriveKey()` requires just `deriveKey` in the `usages` of the
`baseKey` parameter. The `deriveBits` usage is not required to be
allowed. This is the uniform behaviour in Node, Chrome and Firefox.
- The impl currently has userland-accessible `SubtleCrypto.deriveKey()`
and `SubtleCrypto.deriveBits()`, as well as an internal `deriveBits()`
(this is the one that accesses the ffi).
- Also, `SubtleCrypto.deriveKey()` checks if `deriveKey` is an allowed
usage and `SubtleCrypto.deriveBits()` checks if `deriveBits` is an
allowed usage, as required.
- However, the impl currently calls the userland accessible
`SubtleCrypto.deriveBits()` in `SubtleCrypto.deriveKey()`, leading to an
error being thrown if the `deriveBits` usage isn't present.
- Fixed this by making it call the internal `deriveBits()`
instead.
2023-06-19 13:26:58 +05:30
Igor Zinkovsky
0773463de1
chore(kv) fix and re-enable queue test (#19529)
The callback draining code is no longer needed after #19513.
2023-06-17 15:02:32 -07:00
Ryan Clements
d32287d211
fix(ext/node): remove fromFileUrl from "node:path" (#19504) 2023-06-16 19:43:59 +09:00
denobot
239dc5e681
chore: forward v1.34.3 release commit to main (#19526)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-16 01:55:31 +02:00
markthree
43d5644048
refactor(ext/fetch): const for max header cache size (#19496) 2023-06-15 18:27:21 +02:00
Vedant Pandey
0c50c39c35
fix(node): Worker constructor doesn't check type: module of package.json (#19480) 2023-06-15 17:00:30 +02:00
Bartek Iwańczuk
f145cbfacc
refactor(ext/fetch): simplify fetch ops (#19494)
Addresses feedback from
https://github.com/denoland/deno/pull/19412#discussion_r1227912676
2023-06-15 15:34:21 +02:00
Leo Kettmeir
fc4e4c3e93
chore(ext/node): bring back changes to ClientRequest.onSocket (#19509)
Reverts denoland/deno#19426
2023-06-14 22:59:27 +02:00
Bartek Iwańczuk
348287825c
perf(web): optimize timer resolution (#19493)
Closes https://github.com/denoland/deno/issues/19348

This changes benchmark from the issue from:
```
deno run -A https://raw.githubusercontent.com/nats-io/nats.deno/deno-transport-changes/examples/bench.js --subject a --payload 3500 --pub --count 650000
pub 7,636 msgs/sec - [85.13 secs] ~ 25.49 MB/sec 85127.8765/85127.8765
```
to:
```
> ./target/release/deno run -A https://raw.githubusercontent.com/nats-io/nats.deno/deno-transport-changes/examples/bench.js --subject a --payload 3500 --pub --count 650000
pub 176,840 msgs/sec - [3.68 secs] ~ 590.27 MB/sec 3675.646833/3675.646833

> ./target/release/deno run -A https://raw.githubusercontent.com/nats-io/nats.deno/deno-transport-changes/examples/bench.js --subject a --payload 3500 --pub --count 650000
pub 174,589 msgs/sec - [3.72 secs] ~ 582.76 MB/sec 3723.01925/3723.01925
```
2023-06-14 17:04:49 +02:00
Bartek Iwańczuk
5ef225853c
perf: don't run microtask checkpoint if macrotask callback did no work (#19492)
Most of the time there's no firing timers, nor pending promise
rejections, so it's wasteful to run microtask checkpoint 
additionally twice on each tick of the event loop.

Closes https://github.com/denoland/deno/issues/18871
Ref https://github.com/denoland/deno/issues/19451
2023-06-14 16:21:06 +02:00
Jhan S. Álvarez
4b67ffe11b
fix(ext/http): Include hostname in onListen argument (#19497)
Closes #19470.
2023-06-14 06:58:41 -06:00
Igor Zinkovsky
fd9d6baea3
feat(kv) queue implementation (#19459)
Extend the unstable `Deno.Kv` API to support queues.
2023-06-13 17:49:57 -07:00
Bartek Iwańczuk
60bf79c184
Revert "refactor(core): cleanup feature flags for js source inclusion… (#19490)
… (#19463)"

This reverts commit ceb03cfb03.

This is being reverted because it causes 3.5Mb increase in the binary
size,
due to runtime JS code being included in the binary, even though it's
already snapshotted.

CC @nayeemrmn
2023-06-13 22:36:16 +00:00
Leo Kettmeir
92e7287f4a
fix(node/buffer): make slice be the same as subarray (#19481) 2023-06-13 21:26:28 +02:00
Bartek Iwańczuk
7e81d3c876
perf(http): cache verified headers (#19465)
Use `Map` to cache validated HTTP headers. Cache
has a capacity of 4096 elements and it's cleared
once that capacity is reached.

In `preactssr` benchmark it lowers the time spent
when adding headers from 180ms to 2.5ms.
2023-06-13 21:13:34 +02:00
Matt Mastracci
133f9a952b
fix(ext/http): replace await Deno.serve with await Deno.serve().finished (#19485)
We have a bunch of these to clean up after we changed the API.
2023-06-13 18:05:23 +00:00
Matt Mastracci
72da18dd47
fix(ext/websockets): ensure we fully send frames before close (#19484)
Fixes #19483
2023-06-13 17:16:17 +00:00
Nayeem Rahman
ceb03cfb03
refactor(core): cleanup feature flags for js source inclusion (#19463)
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature
`include_js_for_snapshotting` since they leak paths that are only
applicable in this repo to embedders. Replace with feature
`exclude_js_sources`. Additionally the feature
`force_include_js_sources` allows negating it, if both features are set.
We need both of these because features are additive and there must be a
way of force including sources for snapshot creation while still having
the `exclude_js_sources` feature. `force_include_js_sources` is only set
for build deps, so sources are still excluded from the final binary.

You can also specify `force_include_js_sources` on any extension to
override the above features for that extension. Towards #19398.

But there was still the snapshot-from-snapshot situation where code
could be executed twice, I addressed that by making `mod_evaluate()` and
scripts like `core/01_core.js` behave idempotently. This allowed
unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into
`ext::init()`.
2023-06-13 09:45:06 -06:00
Bartek Iwańczuk
07cbec4a82
fix(ext/node): handle 'upgrade' responses (#19412)
This commit adds support for "upgrade" events in "node:http"
"ClientRequest". Currently only "Websocket" upgrades are
handled. Thanks to this change package like "npm:puppeteer"
and "npm:discord" should work.

Closes https://github.com/denoland/deno/issues/18913
Closes https://github.com/denoland/deno/issues/17847
2023-06-13 14:11:27 +02:00
Leo Kettmeir
b4ae37a617
feat(node): HTTPS server (#19362) 2023-06-13 04:15:08 +02:00
Matt Mastracci
d2c638464d
chore(ext/http): fix github lint issue (#19479) 2023-06-13 02:59:41 +02:00
Matt Mastracci
397b22eccf
perf(ext/http): from_maybe_shared_unchecked for header values (#19478)
Prevents re-checking strings we already know are latin-1. Small
improvement: 115k->116k
2023-06-12 23:43:49 +00:00
VlkrS
ea97af312f
feat: Adaptations to support OpenBSD port (#19153) 2023-06-12 13:14:27 +03:00
Marvin Hagemeister
f3326eebd6
perf(serve): hoist promise error callback (#19456) 2023-06-10 12:17:56 +02:00
Bartek Iwańczuk
848cda619e
perf: optimize ByteString checks, hoist server rid getter (#19452)
Further improves preact SSR and express benches by about 2k RPS.

Ref https://github.com/denoland/deno/issues/19451
2023-06-09 22:45:56 +00:00
Marvin Hagemeister
ed76456059
perf(serve): hoist repeated condition (#19449) 2023-06-09 23:21:26 +02:00
denobot
1b26f3c726
chore: forward v1.34.2 release commit to main (#19434)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-09 02:17:03 +00:00
Bartek Iwańczuk
c775001466
chore(ext/node): revert changes to ClientRequest.onSocket (#19426)
Partially reverts https://github.com/denoland/deno/pull/19340
because it causes hangs in some situations.
2023-06-08 20:32:26 +02:00
Matt Mastracci
1d4c66308c
fix(ext/websocket): Close socket on bad string data (#19424) 2023-06-08 18:29:26 +00:00
Matt Mastracci
976c381045
perf(ext/websocket): Reduce GC pressure & monomorpize op_ws_next_event (#19405)
Reduce the GC pressure from the websocket event method by splitting it
into an event getter and a buffer getter.

Before:
165.9k msg/sec

After:
169.9k msg/sec
2023-06-08 09:32:08 -06:00
Matt Mastracci
f35161d3c5
chore: Ensure we only end up with the clang version we want & upgrade libffi (#19421)
The number of clang versions installed on the build machines is too dang
high.
2023-06-08 15:16:24 +00:00
nasa
caad79ef78
feat(node_compat): Add a write method to the FileHandle class (#19385)
## WHY 

ref: https://github.com/denoland/deno/issues/19165

The FileHandle class has many missing methods compared to node.

## WHAT


Add write method
2023-06-08 08:47:12 -06:00
nasa
262571e63e
feat(node_compat): Add a read method to the FileHandle class (#19359)
ref: #19165

The FileHandle class has many missing methods compared to node.
2023-06-08 06:37:19 -06:00
Bartek Iwańczuk
0197f42e6b
perf: use sendto syscalls (#19414)
This switches syscall used in HTTP and WS server from "writev"
to "sendto".

"DENO_USE_WRITEV=1" can be used to enable using "writev" syscall.
Doing this for easier testing of various setups.
2023-06-08 12:55:33 +02:00
Bartek Iwańczuk
90c2bcdcf8
fix(napi): don't panic if symbol can't be found (#19397)
This should return an error to the caller to make it
easier to track what went wrong. 

Should help with debugging https://github.com/denoland/deno/issues/19389
2023-06-07 23:26:41 +00:00
Bartek Iwańczuk
19f82b0eaa
refactor(core): use JoinSet instead of FuturesUnordered (#19378)
This commit migrates "deno_core" from using "FuturesUnordered" to
"tokio::task::JoinSet". This makes every op to be a separate Tokio task
and should unlock better utilization of kqueue/epoll.

There were two quirks added to this PR:
- because of the fact that "JoinSet" immediately polls spawn tasks,
op sanitizers can give false positives in some cases, this was
alleviated by polling event loop once before running a test with 
"deno test", which gives canceled ops an opportunity to settle
- "JsRuntimeState::waker" was moved to "OpState::waker" so that FFI
API can still use threadsafe functions - without this change the
registered wakers were wrong as they would not wake up the 
whole "JsRuntime" but the task associated with an op

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-06-07 23:50:14 +02:00
David Sherret
7e91f74d2b
chore: downgrade to Rust 1.69 (#19407) 2023-06-07 21:02:43 +00:00
Bartek Iwańczuk
42c10ecfdb
perf(ext/websocket): monomorphize code (#19394)
Using `deopt-explorer` I found that a bunch of fields on `WebSocket`
class were polymorphic. 

Fortunately it was enough to initialize them to `undefined`
to fix the problem.
2023-06-07 11:54:49 +02:00
Marvin Hagemeister
1c3d2132c2
perf(http): avoid flattening http headers (#19384) 2023-06-06 16:55:37 +02:00
Leo Kettmeir
5aca8b9e5d
fix(node/http): use fake socket and proper url handling (#19340)
Fixes https://github.com/denoland/deno/issues/19349

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06 14:37:10 +00:00
Matt Mastracci
df76a062fa
perf(ext/websocket): Make send sync for non-stream websockets (#19376)
No need to go through the async machinery for `send(String | Buffer)` --
we can fire and forget, and then route any send errors into the async
call we're already making (`op_ws_next_event`).

Early benchmark on MacOS:

Before: 155.8k msg/sec
After: 166.2k msg/sec (+6.6%)

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06 07:58:18 -06:00
Matt Mastracci
42991017e9
feat(ext/node): Very basic node:http2 support (#19344)
This commit adds basic support for "node:http2" module. Not
all APIs have been yet implemented, but this change already
allows to use this module for some basic functions. 

The "grpc" package is still not working, but it's a good stepping
stone.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06 12:29:55 +02:00
ud2
2052ba343c
fix(ext/console): fix inspecting large ArrayBuffers (#19373) 2023-06-06 11:06:00 +02:00
Matt Mastracci
0bbdbace02
refactor(core): ensureFastOps is an op-generating proxy (#19377)
Startup benchmark shows no changes (within 1ms, identical system/user
times).
2023-06-06 11:01:28 +02:00
David Sherret
5c55f2b4fb
chore: upgrade to Rust 1.70.0 (#19345)
Co-authored-by: linbingquan <695601626@qq.com>
2023-06-06 00:35:39 +00:00
Kenta Moriuchi
d54ef02dfe
chore: update deno_lint to 0.46.0 (#19372) 2023-06-05 15:57:01 -04:00
Levente Kurusa
11dd5a0ae7
fix(ext/crypto): fix JWK import of Ed25519 (#19279)
Fixes: #18049

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-05 14:52:02 +02:00
nasa
d2047f1337
feat(node_compat): Add a close method to the FileHandle class. (#19357)
## WHY 

ref: https://github.com/denoland/deno/issues/19165

The FileHandle class has many missing methods compared to node.
Add these.

## WHAT

- Add close method

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-06-05 06:43:04 -06:00
Leo Kettmeir
08bd23970d
feat: add more options to Deno.inspect (#19337)
For https://github.com/denoland/deno_std/issues/3404

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-06-05 12:25:47 +02:00
Bartek Iwańczuk
21c2c01ebe
perf: optimize RegExp usage in JS (#19364)
Towards https://github.com/denoland/deno/issues/19330

Shows about 1% improvement in the HTTP benchmark.
2023-06-05 10:52:40 +02:00
Koen
adf41edda1
fix(ext/web): Copy EventTarget list before dispatch (#19360)
Related issue: https://github.com/denoland/deno/issues/19358.

This is a regression that seems to have been introduced in
https://github.com/denoland/deno/pull/18905. It looks to have been a
performance optimization.

The issue is probably easiest described with some code:
```ts
const target = new EventTarget();
const event = new Event("foo");
target.addEventListener("foo", () => {
  console.log('base');
  target.addEventListener("foo", () => {
    console.log('nested');
  });
});
target.dispatchEvent(event);
```
Essentially, the second event listener is being attached while the `foo`
event is still being dispatched. It should then not fire that second
event listener, but Deno currently does.
2023-06-04 18:03:44 -06:00
Kamil Ogórek
7d0853d158
perf(ext/http): Migrate op_http_get_request_method_and_url to v8::Array (#19355)
Tackles 3rd item from https://github.com/denoland/deno/issues/19330
list.

Before: 113.9k
After: 114.3k
2023-06-03 12:15:53 -06:00
Kamil Ogórek
260d2ec3a1
perf(ext/http): Migrate op_http_get_request_headers to v8::Array (#19354) 2023-06-02 22:31:27 +00:00
Igor Zinkovsky
ce5bf9fb2a
fix(kv) run sqlite transactions via spawn_blocking (#19350)
`rusqlite` does not support async operations; with this PR SQLite
operations will run through `spawn_blocking` to ensure that the event
loop does not get blocked.

There is still only a single SQLite connection. So all operations will
do an async wait on the connection. In the future we can add a
connection pool if needed.
2023-06-02 11:12:26 -07:00
Kamil Ogórek
98320ff1f8
perf(ext/http): Use flat list of headers for multiple set/get methods (#19336)
This PR attempts to resolve the first item on the list from
https://github.com/denoland/deno/issues/19330 which is about using a
flat list of interleaved key/value pairs, instead of a nested array of
tuples.

I can tackle some more if you can provide a quick example of using raw
v8 arrays, cc @mmastrac
2023-06-02 09:59:16 -06:00
Marvin Hagemeister
f5c1ff08e6
fix(node): map stdio [0, 1, 2] to "inherit" (#19352)
<!--
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.
-->
Internally, `node-tap` spawns a child process with `stdio: [0, 1, 2]`.
Whilst we don't support passing fd numbers as an argument so far, it
turns out that `[0, 1, 2]` is equivalent to `"inherit"` which we already
support. See: https://nodejs.org/api/child_process.html#optionsstdio

Mapping it to `"inherit"` is fine for us and gets us one step closer in
getting `node-tap` working. I'm now at the stage where already the
coverage table is shown 🎉
2023-06-02 09:46:50 -06:00
nasa
25fdc7bf6c
feat(node_compat): Added base implementation of FileHandle (#19294)
<!--
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.
-->


## WHY

ref: https://github.com/denoland/deno/issues/19165

Node's fs/promises includes a FileHandle class, but deno does not. The
open function in Node's fs/promises returns a FileHandle, which provides
an IO interface to the file. However, deno's open function returns a
resource id.


### deno 

```js
> const fs = await import("node:fs/promises");
undefined
> const file3 = await fs.open("./README.md");
undefined
> file3
3
> file3.read
undefined
Node:
```

### Node
```js
> const fs = await import("fs/promises");
undefined
>   const file3 = await fs.open("./tests/e2e_unit/testdata/file.txt");
undefined
> file3
FileHandle {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  close: [Function: close],
  [Symbol(kCapture)]: false,
  [Symbol(kHandle)]: FileHandle {},
  [Symbol(kFd)]: 24,
  [Symbol(kRefs)]: 1,
  [Symbol(kClosePromise)]: null
}
> file3.read
[Function: read]
```


To be compatible with Node, deno's open function should also return a
FileHandle.

## WHAT

I have implemented the first step in adding a FileHandle.

- Changed the return value of the open function to a FileHandle object
- Implemented the readFile method in FileHandle
- Add test code


## What to do next
This PR is the first step in adding a FileHandle, and there are things
that should be done next.

- Add functionality equivalent to Node's FileHandle to FileHandle
(currently there is only readFile)

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-06-02 08:28:05 -06:00
Bartek Iwańczuk
c908088a03
fix(node): don't close stdio streams (#19256)
Closes https://github.com/denoland/deno/issues/19255

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-06-02 07:36:51 +02:00
Bartek Iwańczuk
5557285689
chore(ext/http): add env var to disable writev syscall (#19338) 2023-06-01 08:07:26 -06:00
Hirotaka Tagawa / wafuwafu13
1a0445dc6b
chore(node_compat): add deno task for setting up and running tests (#19293) 2023-06-01 17:31:06 +09:00
Matt Mastracci
077d3d1bb3
refactor(ext/http): Expose internal serveHttpOnListener API for HTTP2 (#19331)
For the first implementation of node:http2, we'll use the internal
version of `Deno.serve` which allows us to listen on a raw TCP
connection rather than a listener.

This is mostly a refactoring, and hooking up of `op_http_serve_on` that
was never previously exposed (but designed for this purpose).
2023-05-31 23:20:39 +00:00
Matt Mastracci
b1e28b0708
chore(ext/node): Implement stubs for Http2Session (#19329)
Fleshes out all the stubs for `node:http2`.
2023-05-31 12:39:54 -06:00
Leo Kettmeir
6e0bf093c5
refactor: further work on node http client (#19327)
Closes https://github.com/denoland/deno/issues/18300
2023-05-31 20:06:21 +02:00
Marvin Hagemeister
d0efd040c7
fix(node): add missing process.reallyExit method (#19326)
This PR adds the missing `process.reallyExit()` method to node's
`process` object.

Was [pinged on
twitter](https://twitter.com/biwanczuk/status/1663326659787862017)
regarding running the `fastify` test suite in node. They use `node-tap`
which has been around arguably the longest of the test frameworks and
relies on a couple of old APIs. They have `signal-exit` as a dependency
which in turn [makes use of
`process.reallyExit()`](8fa7fc9a9c/src/index.ts (L19)).
That function cannot be found anywhere in their documentation, but
exists at runtime. See
6a6b3c5402/lib/internal/bootstrap/node.js (L172)

This doesn't yet make `node-tap` work, but gets us one step closer.
2023-05-31 12:20:38 +02:00
Matt Mastracci
489d2e81c3
perf(ext/http): Add a sync phase to http serving (#19321)
Under heavy load, we often have requests queued up that don't need an
async call to retrieve. We can use a fast path sync op to drain this set
of ready requests, and then fall back to the async op once we run out of
work.

This is a .5-1% bump in req/s on an M2 mac. About 90% of the handlers go
through this sync phase (based on a simple instrumentation that is not
included in this PR) and skip the async machinery entirely.
2023-05-30 18:02:52 -06:00
Bartek Iwańczuk
acc6cdc0b1
chore: forward v1.34.1 to main (#19312)
Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2023-05-29 20:26:03 -06:00
Bartek Iwańczuk
7f5a61c859
pin enum-as-inner dependency (#19311)
Ref https://github.com/bluejekyll/enum-as-inner/issues/98

Had to pin it during the release to publish crates.
2023-05-30 01:55:38 +00:00
Bartek Iwańczuk
d90a75c036
fix: use proper ALPN protocols if HTTP client is HTTP/1.1 only (#19303)
Closes https://github.com/denoland/deno/issues/16923

---------

Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-05-29 23:05:45 +02:00
Bartek Iwańczuk
cf8b7bb530
fix(node): http.IncomingMessageForClient.complete (#19302)
Closes https://github.com/denoland/deno/issues/19238
2023-05-29 01:29:01 +02:00
Nayeem Rahman
b6a3f8f722
refactor(core): remove ext: modules from the module map (#19040)
Rather than disallowing `ext:` resolution, clear the module map after
initializing extensions so extension modules are anonymized. This
operation is explicitly called in `deno_runtime`. Re-inject `node:`
specifiers into the module map after doing this.

Fixes #17717.
2023-05-28 12:44:41 -06:00
Levente Kurusa
bb0676d3e2
fix(ext/http): fix a possible memleak in Brotli (#19250)
We probably need to free the BrotliEncoderState once the stream has
finished.
2023-05-28 12:30:55 -06:00
Leo Kettmeir
be59e93220
refactor(node/http): don't use readablestream for writing to request (#19282)
Refactors the internal usage of a readablestream to write to the
resource directly

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-27 15:42:20 +02:00
Bartek Iwańczuk
a11681a9b0
refactor(node): use internal io and fs APIs (#19267) 2023-05-26 16:18:27 +02:00
Bartek Iwańczuk
160fe9787e
fix(node): make 'v8.setFlagsFromString' a noop (#19271)
Towards https://github.com/denoland/deno/issues/16460
2023-05-26 15:41:03 +02:00
Bartek Iwańczuk
512d5337c4
fix(napi): clear currently registering module slot (#19249)
This commit fixes problem with loading N-API modules that use 
the "old" way of registration (using "napi_module_register" API).
The slot was not cleared after loading modules, causing subsequent
calls that use the new way of registration (using 
"napi_register_module_v1" API) to try and load the previous module.

Ref https://github.com/denoland/deno/issues/16460

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-05-26 10:10:17 +05:30
Hirotaka Tagawa / wafuwafu13
0a3d355ce6
chore(node_compat): fix broken link and typo (#19265) 2023-05-26 05:00:29 +02:00
denobot
935071dd0e
1.34.0 (#19246)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24 23:38:01 +00:00
Levente Kurusa
9ddb39d4cd
fix(ext/node): ClientRequest.setTimeout(0) should remove listeners (#19240)
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2023-05-24 22:54:12 +02:00
Hirotaka Tagawa / wafuwafu13
114ec3c1f7
feat(ext/fs): add isBlockDevice, isCharDevice, isFifo, isSocket to FileInfo (#19008)
`isFile`, `isDirectory`, `isSymlink` are defined in `Deno.FileInfo`, but
`isBlockDevice`, `isCharacterDevice`, `isFIFO`, `isSocket` are not
defined.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24 21:18:13 +02:00
Levente Kurusa
1174715f99
feat(ext/http): Brotli Compression (#19216)
Add Brotli streaming compression to HTTP
2023-05-24 19:54:47 +02:00
Bartek Iwańczuk
0bb5bbc7a0
fix(node): fire 'unhandledrejection' event when using node: or npm: imports (#19235)
This commit fixes emitting "unhandledrejection" event when there are
"node:" or "npm:" imports. 

Before this commit the Node "unhandledRejection" event was emitted
using a regular listener for Web "unhandledrejection" event. This
listener was installed before any user listener had a chance to be 
installed which effectively prevent emitting "unhandledrejection" 
events to user code.

Closes https://github.com/denoland/deno/issues/16928
2023-05-24 15:40:41 +02:00
Yoshiya Hinosawa
26f42a248f
fix(ext/node): add basic node:worker_threads support (#19192)
This PR restores `node:worker_threads` implementation and test cases
from
[`std@0.175.0/node`](https://github.com/denoland/deno_std/blob/0.175.0/node/worker_threads.ts).

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-23 20:56:29 +02:00
Marvin Hagemeister
8608105208
fix(node): duplicate node_module suffixes (#19222)
Noticed that we're checking more module paths than necessary. In
particular the module path array contains a couple of entries with a
duplicated `node_modules/node_modules` suffix.

```js
[
    // ... more entries before here, where some also contain duplicate suffixes
    "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules/.deno/node_modules",
    "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules/node_modules", // <-- duplicate suffix
    "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules",
    "/Users/marvinhagemeister/dev/node_modules",
    "/Users/marvinhagemeister/node_modules",
    "/Users/node_modules",
    "/node_modules",
    "/node_modules"  // <-- duplicate entry
]
```

This was caused by a misunderstanding in how Rust's
[`Path::ends_with()`](https://doc.rust-lang.org/std/path/struct.Path.html#method.ends_with)
works. It's designed to match on whole path segments and the suffix
`/node_modules` is not that, except for the root entry. This meant that
our check for if the path already ended with `node_module` always
returned `false`. Removing the leading slash fixes that.

While we're at it, we can remove the last condition where we explicitly
added the root `/node_modules` entry since the while loop prior to that
takes care of it already.
2023-05-23 12:46:14 +02:00
Leo Kettmeir
5878258952
refactor: further work on node http client (#19211) 2023-05-23 03:03:10 +02:00
Bartek Iwańczuk
25232fa4e8
fix(node): make sure "setImmediate" is not clamped to 4ms (#19213)
This commit changes implementation of "setImmediate"
from "node:timers" module to 0ms timer that is never
clamped to 4ms no matter how many nested calls there are.

Closes https://github.com/denoland/deno/issues/19034
2023-05-22 22:19:44 +00:00
Bartek Iwańczuk
ffd3ed9b8a
fix(ext/web): improve timers resolution for 0ms timeouts (#19212)
This commit changes the implementation of `ext/web` timers, by using
"op_void_async_deferred" for timeouts of 0ms.

0ms timeout is meant to be run at the end of the event loop tick and
currently Tokio timers that we use to back timeouts have at least 1ms
resolution. That means that 0ms timeout actually take >1ms. This
commit changes that and runs 0ms timeout at the end of the event
loop tick.

One consequence is that "unrefing" a 0ms timer will actually keep
the event loop alive (which I believe actually makes sense, the test
we had only worked because the timeout took more than 1ms).

Ref https://github.com/denoland/deno/issues/19034
2023-05-22 14:09:31 +02:00
Bartek Iwańczuk
40bda07ff5
fix(node): add http.Server.unref() (#19201)
Closes https://github.com/denoland/deno/issues/19113
2023-05-22 01:02:10 +02:00
Leo Kettmeir
3e03865d89
feat(unstable): add more options to Deno.createHttpClient (#17385) 2023-05-21 03:43:54 +02:00
Matt Mastracci
7f5290b694
feat(ext/http): ref/unref for server (#19197)
Add `ref` and `unref` to return value from `Deno.serve`. Unblocks #3326.
2023-05-19 15:14:40 -06:00
Matt Mastracci
2b92efa645
feat(ext/http): Add support for trailers w/internal API (HTTP/2 only) (#19182)
Necessary for #3326. 

Requested in #10214 as well.
2023-05-18 20:10:25 -06:00
Bartek Iwańczuk
5b07522349
BREAKING(unstable): change return type of Deno.serve() API (#19189)
This commit changes the return type of an unstable `Deno.serve()` API
to instead return a `Deno.Server` object that has a `finished` field.

This change is done in preparation to be able to ref/unref the HTTP
server.
2023-05-19 02:59:23 +02:00
Marvin Hagemeister
ff0daa2b9d
fix(npm): process not defined in readline (#19184)
Issue was that we create node globals much later, so pulling `process`
via a module import is the way to go.

Fixes #19183
2023-05-18 15:42:27 -04:00
denobot
877b38b370
chore: forward v1.33.4 release commit to main (#19181)
**THIS PR HAS GIT CONFLICTS THAT MUST BE RESOLVED**

This is the release commit being forwarded back to main for 1.33.4

Please ensure:
- [x] Everything looks ok in the PR
- [ ] The release has been published

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

Don't need this PR? Close it.

cc @levex

Co-authored-by: levex <levex@users.noreply.github.com>
Co-authored-by: Levente Kurusa <lkurusa@kernelstuff.org>
2023-05-18 20:44:10 +02:00
Divy Srivastava
6241a657ae
fix(ext/websocket): order of ws writes (#19131)
Fixes https://github.com/denoland/deno/issues/19041
2023-05-18 20:16:19 +05:30
Bartek Iwańczuk
26a64b4edd
refactor(napi): simplify types (#19179)
This commit removes "Error" and "Result" structs from
"ext/napi". In turn all NAPI functions now return "napi_status"
instead of "napi::Result".
2023-05-18 16:17:53 +02:00
Marcos Casagrande
b0f13560cb
fix(ext/webidl): change createPromiseConverter (#16367) 2023-05-18 17:05:11 +03:00
Divy Srivastava
c3f7e6ed6e
fix(cli/napi): handle finalizers (#19168)
Fixes https://github.com/denoland/deno/issues/17325
2023-05-18 19:15:47 +05:30
Marvin Hagemeister
695b5de6cb
fix(node): support passing parent stdio streams (#19171)
This is a bit bare bones but gets `npm-run-all` working. For full stdio
compatibility with node more work is needed which is probably better
done in follow up PRs.

Fixes #19159
2023-05-18 14:02:14 +02:00
Matt Mastracci
ad22336245
feat(ext/web): Request higher-resolution timer on Windows if user requests setTimeout w/short delay (#19149)
If a timer is requested with <=100ms resolution, request the high-res
timer. Since the default Windows timer period is 15ms, this means a
100ms timer could fire at 115ms (15% late). We assume that timers longer
than 100ms are a reasonable cutoff here.

The high-res timers on Windows are still limited. Unfortuntely this
means that our shortest duration 4ms timers can still be 25% late, but
without a more complex timer system or spinning on the clock itself,
we're somewhat bounded by the OS' scheduler itself.
2023-05-17 13:59:55 -06:00
Bartek Iwańczuk
1541c2ac9b
fix(node): export diagnostics_channel module (#19167)
Closes https://github.com/denoland/deno/issues/19166
2023-05-17 12:29:50 +00:00
Luca Casonato
6a78551635
fix(ext/node): make nodeGlobalThis configurable (#19163) 2023-05-17 15:23:18 +03:00
Yoshiya Hinosawa
243d9c846d
fix(ext/node): fix whatwg url formatting (#19146) 2023-05-17 14:51:51 +09:00
Bartek Iwańczuk
f59b1d8a30
fix(node): export punycode module (#19151)
Closes https://github.com/denoland/deno/issues/19147
2023-05-17 14:07:19 +09:00
Bartek Iwańczuk
cb87cb0283
fix: support "fetch" over HTTPS for IP addresses (#18499)
This commit adds support for connecting to IP addresses over HTTPS.

This is done by updating "rustls" to "0.21.0" and other related crates.

Closes https://github.com/denoland/deno/issues/7660
Closes https://github.com/denoland/deno/issues/17967

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-05-17 02:19:23 +02:00
Leo Kettmeir
867a6d3032
refactor(node): reimplement http client (#19122)
This commit reimplements most of "node:http" client APIs using
"ext/fetch".

There is some duplicated code and two removed Node compat tests that
will be fixed in follow up PRs.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-17 01:20:32 +02:00
Matt Mastracci
a22388bbd1
fix(ext/http): Ensure cancelled requests don't crash Deno.serve (#19154)
Fixes for various `Attemped to access invalid request` bugs (#19058,
#15427, #17213).

We did not wait for both a drop event and a completion event before
removing items from the slab table. This ensures that we do so.

In addition, the slab methods are refactored out into `slab.rs` for
maintainability.
2023-05-16 17:00:59 -06:00
Andreu Botella
9ba2c4c42f
fix(fetch): Correctly decode multipart/form-data names and filenames (#19145)
Currently the `multipart/form-data` parser in
`Request.prototype.formData` and `Response.prototype.formData` decodes
non-ASCII filenames incorrectly, as if they were encoded in Latin-1
rather than UTF-8. This happens because the header section of each
`multipart/form-data` entry is decoded as Latin-1 in order to be parsed
with `Headers`, which only allows `ByteString`s, but the names and
filenames are never decoded correctly. This PR fixes this as a
post-processing step.

Note that the `multipart/form-data` parsing for this APIs in the Fetch
spec is very much underspecified, and it does not specify that names and
filenames must be decoded as UTF-8. However, it does require that the
bodies of non-`File` entries are decoded as UTF-8, and in browsers,
names and filenames always use the same encoding as the body.

Closes #19142.
2023-05-16 17:49:35 +02:00