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

4854 commits

Author SHA1 Message Date
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
Lenni
1c74b41855
docs: fix typos (#19118) 2023-05-16 14:30:16 +02:00
Levente Kurusa
ab9a17eeee
fix(deno/upgrade): allow --version vX.Y.Z (#19139)
Instead of just supporting X.Y.Z, support vX.Y.Z. Otherwise we'll try to
download something like vvX.Y.Z
2023-05-16 03:21:59 +02:00
Levente Kurusa
1171c54952
feat(node/crypto): Builtin Diffie-Hellman Groups (#19137)
Towards #18455
2023-05-16 00:07:58 +02:00
Levente Kurusa
3356173d00
feat(node/crypto): Diffie Hellman Support (#18943)
Support crypto.DiffieHellman class in ext/node/crypto
2023-05-15 19:41:53 +02:00
Matt Mastracci
9845361153
refactor(core): bake single-thread assumptions into spawn/spawn_blocking (#19056)
Partially supersedes #19016.

This migrates `spawn` and `spawn_blocking` to `deno_core`, and removes
the requirement for `spawn` tasks to be `Send` given our single-threaded
executor.

While we don't need to technically do anything w/`spawn_blocking`, this
allows us to have a single `JoinHandle` type that works for both cases,
and allows us to more easily experiment with alternative
`spawn_blocking` implementations that do not require tokio (ie: rayon).

Async ops (+~35%):

Before: 

```
time 1310 ms rate 763358
time 1267 ms rate 789265
time 1259 ms rate 794281
time 1266 ms rate 789889
```

After:

```
time 956 ms rate 1046025
time 954 ms rate 1048218
time 924 ms rate 1082251
time 920 ms rate 1086956
```

HTTP serve (+~4.4%):

Before:

```
Running 10s test @ http://localhost:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    68.78us   19.77us   1.43ms   86.84%
    Req/Sec    68.78k     5.00k   73.84k    91.58%
  1381833 requests in 10.10s, 167.36MB read
Requests/sec: 136823.29
Transfer/sec:     16.57MB
```

After:

```
Running 10s test @ http://localhost:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    63.12us   17.43us   1.11ms   85.13%
    Req/Sec    71.82k     3.71k   77.02k    79.21%
  1443195 requests in 10.10s, 174.79MB read
Requests/sec: 142921.99
Transfer/sec:     17.31MB
```

Suggested-By: alice@ryhl.io
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-14 15:40:01 -06:00
Yoshiya Hinosawa
6bea6b31d3
fix(dts): move BroadcastChannel type to lib.deno.unstable.d.ts (#19108) 2023-05-14 20:27:14 +09:00
Bartek Iwańczuk
226a373c49
fix(lsp): increase default max heap size to 3Gb (#19115) 2023-05-13 19:42:34 +00:00
Yoshiya Hinosawa
ab88dc2c68
chore(ext/node): removed skipped compat test cases (#19109) 2023-05-13 15:26:16 +09:00
Yoshiya Hinosawa
2a0c664840
chore: fix & update node compat config (#19106) 2023-05-13 14:49:11 +09:00
David Sherret
68c0fcb157
refactor(lsp): make RequestMethod private (#19114) 2023-05-12 19:07:40 -04:00
denobot
7476ee34fa
chore: forward v1.33.3 release commit to main (#19111)
**THIS PR HAS GIT CONFLICTS THAT MUST BE RESOLVED**

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

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

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

Don't need this PR? Close it.

cc @levex

Co-authored-by: Levente Kurusa <lkurusa@kernelstuff.org>
2023-05-12 14:47:27 +00:00
David Sherret
a39263e067
fix(lsp): preload documents when deno.documentPreloadLimit changes (#19103) 2023-05-11 21:53:09 -04:00
David Sherret
28a72d5488
feat(lsp): ability to configure document pre-load limit (#19097)
Adds a `deno.preloadLimit` option (ex. `"deno.preloadLimit": 2000`)
which specifies how many file entries to traverse on the file system
when the lsp loads or its configuration changes.

Closes #18955
2023-05-11 17:17:14 -04:00
David Sherret
18e9f4642c
fix(lsp): hard to soft error when unable to get completion info (#19091) 2023-05-11 12:04:27 -04:00
David Sherret
b8495e0377
fix(cli): upgrade to Typescript 5.0.4 (#19090) 2023-05-11 14:12:58 +00:00
Nayeem Rahman
ffb0318e4a
fix(console): handle error when inspecting promise-like (#19083)
Fixes
https://discord.com/channels/684898665143206084/684911491035430919/1105900195406958672.

This was caused by: 
- A `TypeError` from `core.getPromiseDetails()` for promise-likes which
also lead to that code path.
- Swallowing internal formatting errors by returning `undefined`. I've
made it so that a special message is formatted in that case instead
(note that this case is fixed now):
![image](https://github.com/denoland/deno/assets/29990554/65bb9612-60b2-4e31-bf5e-e20976601593)
2023-05-11 15:08:17 +02:00
Nayeem Rahman
2ba9ccc1ab
fix(runtime): ChildProcess::kill() doesn't require additional perms (#15339)
Fixes #15217.
2023-05-11 14:53:45 +02:00
Marvin Hagemeister
f1d0f745d3
fix(node): expose channels in worker_threads (#19086)
This PR ensures that node's `worker_threads` module exports
`MessageChannel`, `MessagePort` and the `BroadcastChannel` API. Fixing
these won't make `esbuild` work, but brings us one step closer 🎉

Fixes #19028 .
2023-05-11 12:32:19 +02:00
David Sherret
28aa489de9
feat(compile): unstable npm and node specifier support (#19005)
This is the initial support for npm and node specifiers in `deno
compile`. The npm packages are included in the binary and read from it via
a virtual file system. This also supports the `--node-modules-dir` flag,
dependencies specified in a package.json, and npm binary commands (ex.
`deno compile --unstable npm:cowsay`)

Closes #16632
2023-05-10 20:06:59 -04:00
Marvin Hagemeister
5fd74bfa1c
feat(node): add Module.runMain() (#19080)
This PR adds the missing `Module.runMain()` function which is required
for tools like `ts-node`.

Fixes #19033
2023-05-11 00:13:45 +02:00
Bartek Iwańczuk
e72485fb17
fix(node): conditional exports edge case (#19082)
Fixes https://github.com/denoland/deno/issues/18743
2023-05-10 23:55:48 +02:00
David Sherret
ec67e96a12
fix(dts): align seekSync position arg with seek (#19077)
Closes #19060
2023-05-10 22:04:30 +02:00
Matt Mastracci
29aa988476
refactor(core): http_next generic over request extractor (#19071) 2023-05-10 16:23:26 +02:00
Matt Mastracci
234cef982c
feat(ext/http): Automatic compression for Deno.serve (#19031)
`Content-Encoding: gzip` support for `Deno.serve`. This doesn't support
Brotli (`br`) yet, however it should not be difficult to add. Heuristics
for compression are modelled after those in `Deno.serveHttp`.

Tests are provided to ensure that the gzip compression is correct. We
chunk a number of different streams (zeros, hard-to-compress data,
already-gzipped data) in a number of different ways (regular, random,
large/small, small/large).
2023-05-10 13:23:14 +02:00
David Sherret
50618fc0bc
fix(vendor): better handling of redirects (#19063)
Closes #17582
Closes #19057
2023-05-09 21:49:16 +00:00
Luca Casonato
f34fcd16ea
fix(core): let V8 drive extension ESM loads (#18997)
This now allows circular imports across extensions.

Instead of load + eval of all ESM files in declaration order, all files
are only loaded. Eval is done recursively by V8, only evaluating
files that are listed in `Extension::esm_entry_point` fields.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-09 12:37:13 +02:00
David Sherret
723d4b0382
perf(fmt): faster formatting for minified object literals (#19050)
Has fix for
https://github.com/dprint/dprint-plugin-typescript/issues/520
2023-05-09 00:53:58 +02:00
Matt Mastracci
687a939588
fix(ext/http): Ensure Deno.serve works across --watch restarts (#18998)
Fixes #16699 and #18960 by ensuring that we release our HTTP
`spawn_local` tasks when the HTTP resource is dropped.

Because our cancel handle was being projected from the resource via
`RcMap`, the resource was never `Drop`ped. By splitting the handle out
into its own `Rc`, we can avoid keeping the resource alive and let it
drop to cancel everything.
2023-05-08 09:52:56 +02:00
David Sherret
a6c47ee740
refactor(ext/node): combine deno_node::Fs with deno_fs::FileSystem (#18991) 2023-05-05 16:44:24 +00:00
David Sherret
5270c43e41
refactor(ext/fs): boxed deno_fs::FileSystem (#18945)
1. Boxed `File` and `FileSystem` to allow more easily passing this
through the CLI code (as shown within this pr).
2. `StdFileResource` is now `FileResource`. `FileResource` now contains
an `Rc<dyn File>`.
2023-05-04 14:28:42 -04:00
denobot
4b645676d6
chore: forward v1.33.2 release commit to main (#18990)
**THIS PR HAS GIT CONFLICTS THAT MUST BE RESOLVED**

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

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

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

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-04 19:19:35 +02:00
Bartek Iwańczuk
8382adaf7d
docs: update Deno.Writer docstring (#18987)
Closes
https://github.com/denoland/deno/issues/18985#issuecomment-1534493623
2023-05-04 14:37:45 +02:00
Luca Casonato
95e209a0e4
refactor(ext/node): remove NodeEnv trait (#18986) 2023-05-04 14:36:38 +02:00
Nayeem Rahman
7a8bb3b611
fix(core): allow esm extensions not included in snapshot (#18980)
Fixes #18979.

This changes the predicate for allowing `ext:` specifier resolution from
`snapshot_loaded_and_not_snapshotting` to `ext_resolution_allowed` which
is only set to true during the extension module loading phase. Module
loaders as used in core
are now declared as `ExtModuleLoader` rather than `dyn ModuleLoader`.
2023-05-04 02:44:59 +02:00
Nayeem Rahman
e3276fbb71
fix(test): disable preventDefault() for beforeunload event (#18911)
Fixes #18910.
2023-05-03 23:10:51 +02:00
Luca Casonato
d905f20cad
fix(ext/kv): throw on the Kv constructor (#18978)
Closes #18963

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-03 23:08:42 +02:00
kang
632395da89
fix(docs): replace "e.g." with "i.e." in seek()/seekSync() comment (#18964)
Clarify calculation of number "9" in `seek()`/`seekSync()` comment of
lib.deno.ns.d.ts by replacing "e.g." with "i.e."
2023-05-03 20:41:25 +00:00
Luca Casonato
93a78d3d4a
fix(ext/kv): KvU64#valueOf and KvU64 inspect (#18656)
`new Deno.KvU64(1n) + 2n == 3n` is now true.

`new Deno.KvU64(1n)` is now inspected as `[Deno.KvU64: 1n]`
(`Object(1n)` is inspected as `[BigInt: 1n]`).

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-03 11:44:00 +00:00
Bartek Iwańczuk
798c1ad0f1
perf: use jemalloc as global allocator (#18957)
Follow up to https://github.com/denoland/deno/pull/18875 that enables
`jemalloc` as a global allocator for the Deno CLI.
2023-05-03 00:36:33 +02:00
Yarden Shoham
341fc11e24
docs(lib): document Deno.Command requires the allow-run permission (#18958) 2023-05-02 15:51:50 +00:00
Bartek Iwańczuk
97147faf89
chore: release extension crates, unpin tokio (#18954) 2023-05-02 11:30:11 +00:00
Kenta Moriuchi
49eb887cc6
refactor(core): Use ObjectHasOwn instead of ObjectPrototypeHasOwnProperty (#18952)
ES2022 `Object.hasOwn` can be used in snapshot, so I migrate to use it.
2023-05-02 12:15:45 +02:00
Bartek Iwańczuk
2f651b2d64
fix(npm): canonicalize filename before returning (#18948)
This commit changes how paths for npm packages are handled,
by canonicalizing them when resolving. This is done so that instead
of returning
"node_modules/<package_name>@<version>/node_modules/<dep>/index.js"
(which is a symlink) we "node_modules/<dep>@<dep_version>/index.js.

Fixes https://github.com/denoland/deno/issues/18924
Fixes https://github.com/bluwy/create-vite-extra/issues/31

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-05-02 02:35:33 +02:00
Michael Lazarev
2ee55145c0
docs: correct example of piping the output of a subprocess to a file (#18933)
Fixes #18909
2023-05-01 21:52:56 +00:00
David Sherret
913176313b
perf: lazily create RootCertStore (#18938) 2023-05-01 16:42:05 -04:00
David Sherret
9efed4c7a3
refactor(cli): remove ProcState - add CliFactory (#18900)
This removes `ProcState` and replaces it with a new `CliFactory` which
initializes our "service structs" on demand. This isn't a performance
improvement at the moment for `deno run`, but might unlock performance
improvements in the future.
2023-05-01 14:35:23 -04:00
David Sherret
30628288ce
perf: lazily retrieve ppid (#18940)
This is very apparent on Windows.

Before: 45.74ms (Hello world)
After: 33.92ms

Closes #18939
2023-05-01 18:21:27 +00:00
David Sherret
94a148cdb6
refactor(cli): use CliMainWorker in standalone (#18880)
Uses `CliMainWorker` in all the cli code.
2023-05-01 08:59:38 -04:00
Divy Srivastava
d856bfd336
perf(ext/web): fast path for ws events (#18905)
- Do not use `ReflectHas` in `isNode`.
- Avoid copying handler array when handlers.length == 1
- Avoid searching for path target when path.length == 1

```
Linux divy-2 5.19.0-1022-gcp #24~22.04.1-Ubuntu SMP Sun Apr 23 09:51:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
32GiB System memory
Intel(R) Xeon(R) CPU @ 3.10GHz

# main + https://github.com/denoland/deno/pull/18904
Msg/sec: 89326.750000
Msg/sec: 90320.000000
Msg/sec: 89576.250000

# this patch
Msg/sec: 97250.000000
Msg/sec: 97125.500000
Msg/sec: 97964.500000
```
2023-05-01 10:39:30 +05:30
David Sherret
9a9473533e
refactor(cli): remove Clone on ProcState (#18874)
Slowly phasing this out.
2023-04-30 16:51:31 -04:00
David Sherret
96e214d9d0
fix(fmt/json): support formatting number with exponent and no sign (#18894)
Numbers with an exponent and no sign (ex. `1e1`) would fail to parse.
2023-04-30 10:03:39 -04:00
Kenta Moriuchi
74bb09aa38
fix(ext/url): throw TypeError for empty argument (#18896)
Fixes #18893
2023-04-30 12:24:34 +02:00
Leo Kettmeir
59825a95b4
refactor: remove ext/console/01_colors.js (#18927) 2023-04-30 09:11:37 +00:00
Matt Mastracci
bb1f5e4262
perf(core): async op pseudo-codegen and performance work (#18887)
Performance:

```
async_ops.js: 760k -> 1030k (!)
async_ops_deferred.js: 730k -> 770k
Deno.serve bench: 118k -> 124k
WS test w/ third_party/prebuilt/mac/load_test 100 localhost 8000 0 0: unchanged

Startup time: approx 0.5ms slower (13.7 -> 14.2ms)
```
2023-04-30 08:50:24 +00:00
Leo Kettmeir
9c8ebce3dc
refactor: merge Deno & Node inspectors (#18691) 2023-04-30 07:24:13 +00:00
Luca Casonato
1066490847
fix(ext/kv): stricter structured clone serializer (#18914) 2023-04-29 17:43:07 +02:00
denobot
6369098ad7
chore: forward v1.33.1 release commit to main (#18897)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-28 21:14:26 +02:00
Bartek Iwańczuk
142c1ab9fc
fix(ext/websocket): restore op_ws_send_ping (#18891)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-28 16:48:00 +02:00
Nayeem Rahman
0b296c6378
fix(repl): don't panic on undefined exception (#18888)
Fixes regression from #18878 where `Promise.reject()`,
`Promise.reject(undefined)` and `reportError(undefined)` panic in the
REPL.
Fixes `throw undefined` printing `Uncaught Unknown exception` instead of
`Uncaught undefined`.
2023-04-28 15:21:55 +02:00
Luca Casonato
84b921555f
fix(ext/fetch): subview Uint8Array in Req/Resp (#18890) 2023-04-28 14:26:21 +02:00
denobot
39ece1fe0d
1.33.0 (#18879)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-28 01:18:57 +02:00
Bartek Iwańczuk
683dbd7f3b
Revert "refactor: don't expose Deno[Deno.internal].core namespace" (#18881)
Also conditionally disabled one test if there's not enough space on
device.
2023-04-28 00:37:03 +02:00
Nayeem Rahman
504482dadd
fix(repl): print unhandled rejections and event errors (#18878)
Fixes #8858.
Fixes #8869.

```
$ target/debug/deno
Deno 1.32.5
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> Promise.reject(new Error("bar"));
Promise { <rejected> Error: bar
    at <anonymous>:2:16 }
Uncaught (in promise) Error: bar
    at <anonymous>:2:16
> reportError(new Error("baz"));
undefined
Uncaught Error: baz
    at <anonymous>:2:13
>
2023-04-27 23:36:49 +02:00
Bartek Iwańczuk
6cd62ea5e9
chore: upgrade rusty_v8 to 0.71.0 (#18868) 2023-04-27 20:50:46 +02:00
Luca Casonato
3fbb31c3c1
feat(kv): return ok bool from atomic commit (#18873) 2023-04-27 16:59:02 +02:00
Divy Srivastava
b0264bea7d
fix(ext/node): prime generation (#18861)
Towards https://github.com/denoland/deno/issues/18455

`safe`, `add` and `rem` options are not implemented because there is no
rust crate that provides this functionality (except rust-openssl maybe)
and its just not clear if this API is used widely.
2023-04-27 19:40:59 +05:30
David Sherret
742cc3111c
refactor(cli): extract out ProcState from CliMainWorker (#18867) 2023-04-27 10:05:20 -04:00
Nayeem Rahman
03132e19da
fix(test): handle dispatched exceptions from test functions (#18853)
Fixes #18852.
2023-04-27 14:40:03 +02:00
scarf
90a5ef5e34
feat(cli): flatten deno.json configuaration (#17799) 2023-04-26 23:02:36 -04:00
Bartek Iwańczuk
4192978c3a
feat(lint): add Deno.run to no-deprecated-deno-api (#18869)
This upgrade includes a warning for the deprecated "Deno.run()" API.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-04-27 02:52:52 +00:00
Kevin Whinnery
a16ad526e9
docs: Improve inline docs for permissions (deno run --help) (#18757)
Hey there! I took a crack at improving these embedded docs [as requested
here](https://github.com/denoland/deno/issues/18685). These should
accurately reflect the functionality of the permission-related flags for
`deno run`.

### Highlights
* Adds human-readable argument string in the format [prescribed in the
docs](https://docs.rs/clap/latest/clap/struct.Arg.html#method.value_name)
* Keeps text description terse, but includes a relevant copy/pasteable
docs link
* Includes example argument usage/formatting
2023-04-27 02:49:59 +02:00
Bartek Iwańczuk
09b6dbc0a6
feat: Deprecate Deno.run API in favor of Deno.Command (#17630) (#18866)
This commit adds `@deprecated` comments to `Deno.run` API declarations.
Since stabilization of `Deno.Command` API in [Deno
v1.31](https://deno.com/blog/v1.31#api-stabilizations), `Deno.Command`
is the preferred (more reliable) API to interact with subprocesses.
This is the preparation for the removal of `Deno.run` API in Deno 2.0.
2023-04-27 02:11:23 +02:00
David Sherret
f4e442da4d
fix(dts): URLPatternComponentResult groups should have possibly undefined key values (#18643)
Closes #18640
2023-04-26 19:15:25 -04:00
Matt Mastracci
e2761df3fe
fix(ext/http): internal upgradeHttpRaw works with "Deno.serve()" API (#18859)
Fix internal "upgradeHttpRaw" API restoring capability to upgrade HTTP
connection in polyfilles "node:http" API.
2023-04-27 00:58:18 +02:00
Bartek Iwańczuk
7415aff983
bench: fix more benchmarks (#18864) 2023-04-26 21:59:32 +00:00
Nayeem Rahman
3d8a4d3b81
feat(cli): don't check permissions for statically analyzable dynamic imports (#18713)
Closes #17697
Closes #17658
2023-04-26 16:23:28 -04:00
David Sherret
c2f5c09692
chore: fix benchmarks (#18863) 2023-04-26 19:09:28 +00:00
Bartek Iwańczuk
14aaa73c02
refactor: don't expose Deno[Deno.internal].core namespace (#18816) 2023-04-26 19:57:38 +02:00
Ryan Dahl
2df6db36c8
feat(ext/kv): add more atomic operation helpers (#18854)
Co-authored-by: losfair <zhy20000919@hotmail.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-04-26 17:14:01 +00:00
David Sherret
55a9977c62
refactor(compile): remove usage of ProcState and CliOptions (#18855) 2023-04-26 13:07:15 -04:00
Matt Mastracci
38681dfa88
perf(ext/http): optimize for zero or one-packet response streams (#18834)
Improve `deno_reactdom_ssr_flash.jsx` by optimizing for zero/one-packet response streams.
2023-04-26 15:33:30 +02:00
Bartek Iwańczuk
1b450015e7
BREAKING(unstable): remove "Deno.serve(handler, options)" overload (#18759)
In preparation to stabilization of the API this overload was decided to
be removed.
2023-04-26 14:54:03 +02:00
Bartek Iwańczuk
106e4c475f
chore: upgrade rusty_v8 to 0.70.0 (#18844)
Closes https://github.com/denoland/deno/issues/18369
2023-04-26 10:02:03 +02:00
David Sherret
041d1e093b
refactor(cli): extract out NpmModuleLoader from CliModuleLoader (#18842)
Need to share this with the loader used in deno compile
2023-04-25 18:36:31 -04:00
Kenta Moriuchi
9b49de4644
fix(core): Wrap safe collections' argument of primordials (#18750) 2023-04-26 00:36:22 +02:00
Bartek Iwańczuk
531754c354
refactor(ext/websocket): use specialized ops (#18819)
Instead of relying on `op_ws_send` to send different kinds of messages,
use specialized ops everywhere.
2023-04-25 13:53:06 +02:00
Yoshiya Hinosawa
63befe9377
fix(ext/node): fix hash.flush (#18818) 2023-04-25 11:21:26 +09:00
David Sherret
5b4a9b48ae
refactor(ext/node): enforce interior mutable for NodePermissions to remove clones (#18831)
We can make `NodePermissions` rely on interior mutability (which the
`PermissionsContainer` is already doing) in order to not have to clone
everything all the time. This also reduces the chance of an accidental
`borrow` while `borrrow_mut`.
2023-04-24 21:07:48 -04:00
Nayeem Rahman
667acb075c
fix(lsp): show dependency errors for repeated imports (#18807) 2023-04-24 23:52:27 +00:00
David Sherret
aa286fdecb
refactor(ext/node): allow injecting NodeFs from CLI (#18829)
This allows providing a `NodeFs` as part of the `WorkerOptions`.
2023-04-24 19:44:35 -04:00
Matt Mastracci
bb74e75a04
feat(ext/http): h2c for http/2 (#18817)
This implements HTTP/2 prior-knowledge connections, allowing clients to
request HTTP/2 over plaintext or TLS-without-ALPN connections. If a
client requests a specific protocol via ALPN (`h2` or `http/1.1`),
however, the protocol is forced and must be used.
2023-04-24 23:24:40 +02:00
David Sherret
0e97fa4d5f
fix(npm): only include top level packages in top level node_modules directory (#18824)
We were indeterministically including packages in the top level
`node_modules/` folder when using a local node_modules directory. This
change aligns with pnpm and only includes top level packages in this
folder. This should be faster for initializing the folder, but may
expose issues in packages that reference other packages not defined in
their dependencies. That said, the behaviour previously was previously
broken.

This has exposed a bug in the require implementation where it doesn't
find a package (which is the main underlying issue here). There is a
failing test already for this in the test suite after this change.

Closes #18822

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-24 17:08:11 -04:00
Leo Kettmeir
be9e3c430f
docs: add categories to APIs without (#18826) 2023-04-24 20:24:18 +00:00
Bartek Iwańczuk
ebfc75fe8c
test: disable flaky Node test (#18821)
If we hit a slow runner this test almost always fails.
2023-04-24 22:55:06 +09:00
Bartek Iwańczuk
ea0694bbfd
test: deflake worker tests (#18813) 2023-04-23 23:48:25 +00:00
Bartek Iwańczuk
5a524a9a5a
refactor: rewrite client side tests to 'fastwebsockets' crate (#18800)
Follow up to https://github.com/denoland/deno/pull/18781.
2023-04-23 22:55:45 +02:00
Leo Kettmeir
c95477c49f
tests: update tests relying on deno.land (#18811) 2023-04-23 20:07:30 +02:00
Matt Mastracci
13f7f8c415
fix(ext/http): ensure that multiple upgrades and multiple simultaneous requests cannot cause a panic (#18810)
Fix a bug where we weren't saving `slabId` in #18619, plus add some
robustness checks around multiple upgrades (w/test).
2023-04-23 09:59:46 -06:00
Matt Mastracci
bdffcb409f
feat(ext/http): Rework Deno.serve using hyper 1.0-rc3 (#18619)
This is a rewrite of the `Deno.serve` API to live on top of hyper
1.0-rc3. The code should be more maintainable long-term, and avoids some
of the slower mpsc patterns that made the older code less efficient than
it could have been.

Missing features:

- `upgradeHttp` and `upgradeHttpRaw` (`upgradeWebSocket` is available,
however).
- Automatic compression is unavailable on responses.
2023-04-22 11:48:21 -06:00
Levente Kurusa
d137501a63
feat(node/http): implement ClientRequest.setTimeout() (#18783)
- implement setTimeout with matching semantics of Node
- add the test from Node but leave it turned off because ClientRequest
has no underlying socket
2023-04-22 13:20:00 +02:00
Bartek Iwańczuk
068228cb45
refactor: rewrite tests to "fastwebsockets" crate (#18781)
Migrating off of `tokio-tungstenite` crate.

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-22 11:17:31 +02:00
David Sherret
a615eb3b56
refactor(node): move most of cli/node to ext/node (#18797)
This is just a straight refactor and I didn't do any cleanup in
ext/node. After this PR we can start to clean it up and make things
private that don't need to be public anymore.
2023-04-21 21:02:46 -04:00
David Sherret
cf9fb18494
feat: upgrade deno_ast to 0.26 (#18795)
Closes #18792
2023-04-21 21:16:25 +00:00
David Sherret
4a33c349af
refactor: move some CJS and ESM code analysis to ext/node (#18789) 2023-04-21 16:38:10 -04:00
Nayeem Rahman
065d8771ad
fix(test): allow explicit undefined for boolean test options (#18786)
Fixes #18784.
2023-04-21 15:32:37 +02:00
Divy Srivastava
4e944dea1d
fix(ext/websocket): upgrade fastwebsockets to 0.2.4 (#18791)
Fixes https://github.com/denoland/deno/issues/18775
2023-04-21 08:55:02 +02:00
David Sherret
c2e9c8cce5
fix(compile): write bytes directly to output file (#18777)
1. Adds cli/standalone folder
2. Writes the bytes directly to the output file. When adding npm
packages this might get quite large, so let's not keep the final output
in memory just in case.
2023-04-19 21:50:56 +00:00
Levente Kurusa
c336755881
fix(test/coverage): exclude test files (#18748)
Fixes: #18454
2023-04-19 23:30:52 +02:00
Divy Srivastava
9496dfc685
fix(ext/node): implement asymmetric keygen (#18651)
Towards #18455 

This commit implements the keypair generation for asymmetric keys for
the `generateKeyPair` API.

See how key material is managed in this implementation:
https://www.notion.so/denolandinc/node-crypto-design-99fc33f568d24e47a5e4b36002c5325d?pvs=4

Private and public key encoding depend on `KeyObject#export` which is
not implemented. I've also skipped ED448 and X448 since we need a crate
for that in WebCrypto too.
2023-04-19 22:27:34 +05:30
Yoshiya Hinosawa
53c9f5918c
fix(ext/node): improve vm.runInThisContext (#18767) 2023-04-19 23:26:16 +09:00
Yoshiya Hinosawa
fdebb7e793
fix(ext/node): add crypto.sign|verify methods (#18765) 2023-04-19 23:24:26 +09:00
Bartek Iwańczuk
972469d309
tests: disable another flaky test (#18762)
This test is flaky too, it actually shouldn't be running since it's not
listed in `cli/tests/node_compat/config.jsonc` at all.
2023-04-19 00:10:01 +00:00
Bartek Iwańczuk
edca01c35e
chore: disable flaky Node compat tests (#18760)
I'm not able to reproduce any of the failures from CI on my machine.

I'm going to disable these tests for now as they are holding us back.
2023-04-19 00:32:21 +02:00
Bartek Iwańczuk
40d9e918ea
test: fix flaky worker test (#18754)
https://github.com/denoland/deno/actions/runs/4734585198/jobs/8403719901?pr=18753
2023-04-18 22:24:47 +02:00
denobot
4e5d370b56
chore: forward v1.32.5 release commit to main (#18758)
Co-authored-by: levex <levex@users.noreply.github.com>
Co-authored-by: Levente Kurusa <lkurusa@kernelstuff.org>
2023-04-18 22:20:49 +02:00
Levente Kurusa
530963c34c
refactor(node/crypto): scrypt polyfill to rust (#18746) 2023-04-18 14:29:10 +02:00
Yoshiya Hinosawa
74aee8b305
chore(ext/node): restore http_test from std (#18747) 2023-04-18 21:06:25 +09:00
Yoshiya Hinosawa
5f44396a9e
fix(ext/node): implement crypto.createVerify (#18703) 2023-04-18 21:04:51 +09:00
Yoshiya Hinosawa
de21a780fd
fix(ext/node): add req.socket.remoteAddress (#18733) 2023-04-18 16:00:51 +09:00
Yoshiya Hinosawa
6efaef606a
fix(ext/node): polyfill response._implicitHeader method (#18738) 2023-04-18 15:20:36 +09:00
David Sherret
d2d62b6312
refactor(npm): add CliNodeResolver (#18742) 2023-04-17 15:36:23 -04:00
Yoshiya Hinosawa
559a61b879
chore: update node compat config (#18736) 2023-04-18 00:36:49 +09:00
Cre3per
bad4b7554b
refactor(tests): Watcher test timeout (#18459)
Closes #17438
2023-04-17 09:49:03 -04:00
David Sherret
94744ae25a
fix(lsp): ensure language server status works on unix (#18727)
Closes #18724
2023-04-16 16:02:48 -04:00
Bartek Iwańczuk
02dd09a36f
bench: add benchmark for deferred async ops (#18722)
```
./target/release/deno run cli/bench/async_ops_deferred.js
time 794 ms rate 1259445
time 786 ms rate 1272264
time 770 ms rate 1298701
time 784 ms rate 1275510
time 775 ms rate 1290322
time 786 ms rate 1272264
time 773 ms rate 1293661
time 771 ms rate 1297016
time 774 ms rate 1291989
time 767 ms rate 1303780
time 764 ms rate 1308900
time 768 ms rate 1302083
time 763 ms rate 1310615
time 761 ms rate 1314060
time 761 ms rate 1314060
time 762 ms rate 1312335
time 763 ms rate 1310615
time 759 ms rate 1317523
time 760 ms rate 1315789
time 761 ms rate 1314060
time 769 ms rate 1300390
time 763 ms rate 1310615
time 760 ms rate 1315789
time 763 ms rate 1310615
time 761 ms rate 1314060
time 759 ms rate 1317523
time 765 ms rate 1307189
time 760 ms rate 1315789
time 764 ms rate 1308900
time 763 ms rate 1310615
time 760 ms rate 1315789
time 757 ms rate 1321003
time 763 ms rate 1310615
time 759 ms rate 1317523
time 771 ms rate 1297016
time 759 ms rate 1317523
time 759 ms rate 1317523
time 763 ms rate 1310615
time 754 ms rate 1326259
time 755 ms rate 1324503
time 762 ms rate 1312335
time 752 ms rate 1329787
time 755 ms rate 1324503
time 754 ms rate 1326259
time 759 ms rate 1317523
time 754 ms rate 1326259
time 749 ms rate 1335113
time 753 ms rate 1328021
time 756 ms rate 1322751
time 753 ms rate 1328021
```

```
samply record -r 20000 target/release/deno run cli/bench/async_ops_deferred.js
```

https://share.firefox.dev/43Efvm6
2023-04-16 19:47:06 +00:00
Bartek Iwańczuk
1564595f6b
Revert "perf(core): immediately schedule another tick if there are un… (#18718)
…polled ops (#18611)"

This reverts commit 4317055a3e.

Reverting because we discovered while working on
https://github.com/denoland/deno/pull/18619 that it doesn't work
correctly (sometimes waker just stops working).
2023-04-16 14:05:13 +00:00
Ryan Dahl
2184103a5e
feat(kv): AtomicOperation#sum (#18704) 2023-04-15 10:33:31 +02:00
David Sherret
1bca994143
chore: fix running node tests in parallel on Windows (#18711) 2023-04-14 18:50:58 -04:00
David Sherret
0a67a3965f
refactor: add TypeChecker struct (#18709)
Adds a `TypeChecker` struct and pushes more shared functionality into
it.
2023-04-14 18:05:46 -04:00
David Sherret
f6a28e3e62
chore: remove node_modules folder being created in testdata directory (#18708) 2023-04-14 21:56:14 +00:00
David Sherret
136dce67ce
refactor: break up ProcState (#18707)
1. Breaks up functionality within `ProcState` into several other structs
to break out the responsibilities (`ProcState` is only a data struct
now).
2. Moves towards being able to inject dependencies more easily and have
functionality only require what it needs.
3. Exposes `Arc<T>` around the "service structs" instead of it being
embedded within them. The idea behind embedding them was to reduce the
verbosity of needing to pass around `Arc<...>`, but I don't think it was
exactly working and as we move more of these structs to be more
injectable I don't think the extra verbosity will be a big deal.
2023-04-14 16:22:33 -04:00
Divy Srivastava
a411144219
fix(ext/websocket): Avoid write deadlock that requires read_frame to complete (#18705)
Fixes https://github.com/denoland/deno/issues/18700

Timeline of the events that lead to the bug.

1. WebSocket handshake complete
2. Server on `read_frame` holding an AsyncRefCell borrow of the
WebSocket stream.
3. Client sends a TXT frame after a some time
4. Server recieves the frame and goes back to `read_frame`.
5. After some time, Server starts a `write_frame` but `read_frame` is
still holding a borrow!
^--- Locked. read_frame needs to complete so we can resume the write.

This commit changes all writes to directly borrow the
`fastwebsocket::WebSocket` resource under the assumption that it won't
affect ongoing reads.
2023-04-14 22:17:39 +05:30
Bartek Iwańczuk
cb2ca234bb
refactor(core): limit number of boundary crossings between Rust and V8 (#18652)
This commit refactors "deno_core" to do fewer boundary crossings
from Rust to V8. In other words we are now calling V8 from Rust fewer
times.

This is done by merging 3 distinct callbacks into a single one. Instead
of having "op resolve" callback, "next tick" callback and "macrotask
queue" callback, we now have only "Deno.core.eventLoopTick" callback,
which is responsible for doing the same actions previous 3 callbacks.

On each of the event loop we were doing at least 2 boundary crosses
(timers macrotask queue callback and unhandled promise rejection
callback) and up to 4 crosses if there were op response and next tick
callbacks coming from Node.js compatibility layer. Now this is all done
in a single callback.

Closes https://github.com/denoland/deno/issues/18620
2023-04-14 02:41:32 +02:00
David Sherret
d192d84a0e
refactor(cli): add Emitter struct (#18690)
Removes the functions in the `emit` module and replaces them with an
`Emitter` struct that can have "ctor dependencies" injected rather than
using functions to pass along the dependencies.

This is part of a long term refactor to move more functionality out of
proc state.
2023-04-13 18:03:07 +00:00
Nayeem Rahman
6e8618ae0f
refactor(cli): move runTests() and runBenchmarks() to rust (#18563)
Stores the test/bench functions in rust op state during registration.
The functions are wrapped in JS first so that they return a directly
convertible `TestResult`/`BenchResult`. Test steps are still mostly
handled in JS since they are pretty much invoked by the user. Allows
removing a bunch of infrastructure for communicating between JS and
rust. Allows using rust utilities for things like shuffling tests
(`Vec::shuffle`). We can progressively move op and resource sanitization
to rust as well.

Fixes #17122.
Fixes #17312.
2023-04-13 19:43:23 +02:00
David Sherret
4e53bc5a94
chore: bump child_process_test timeouts for slow CI (#18689) 2023-04-13 13:30:30 -04:00
David Sherret
efa7c19890
refactor: upgrade to deno_npm 0.3.0 (#18671)
This allows us to specify the `@types/node` version constraint in the
CLI instead of in deno_npm.
2023-04-13 10:47:45 -04:00
Bartek Iwańczuk
702284dc22
perf(ops): directly respond for eager ops (#18683)
This commit changes "eager ops" to directly return a response value
instead of calling "opresponse" callback in JavaScript. This saves
one boundary crossing and has a fantastic impact on the "async_ops.js"
benchmark:

```
v1.32.4
$ deno run cli/bench/async_ops.js
time 329 ms rate 3039513
time 322 ms rate 3105590
time 307 ms rate 3257328
time 301 ms rate 3322259
time 303 ms rate 3300330
time 306 ms rate 3267973
time 300 ms rate 3333333
time 301 ms rate 3322259
time 301 ms rate 3322259
time 301 ms rate 3322259
time 302 ms rate 3311258
time 301 ms rate 3322259
time 302 ms rate 3311258
time 302 ms rate 3311258
time 303 ms rate 3300330
```

```
this branch
$ ./target/release/deno run -A cli/bench/async_ops.js
time 257 ms rate 3891050
time 248 ms rate 4032258
time 251 ms rate 3984063
time 246 ms rate 4065040
time 238 ms rate 4201680
time 227 ms rate 4405286
time 228 ms rate 4385964
time 229 ms rate 4366812
time 228 ms rate 4385964
time 226 ms rate 4424778
time 226 ms rate 4424778
time 227 ms rate 4405286
time 228 ms rate 4385964
time 227 ms rate 4405286
time 228 ms rate 4385964
time 227 ms rate 4405286
time 229 ms rate 4366812
time 228 ms rate 4385964
```

Prerequisite for https://github.com/denoland/deno/pull/18652
2023-04-13 14:32:47 +02:00
Geert-Jan Zwiers
aaebd6eb42
chore(docs): clarify what subcommands do not type-check by default (#18520)
The CLI docs suggested that all deno subcommands no longer type-check by
default. This is only the case for some subcommands, and this PR
clarifies the CLI docs in this regard.
2023-04-13 03:42:28 +02:00
Yiyu Lin
d790ea7d53
refactor(cli,ext,ops): cleanup regex with lazy-regex (#17296)
- bump deps: the newest `lazy-regex` need newer `oncecell` and
`regex`
- reduce `unwrap`
- remove dep `lazy_static`
- make more regex cached

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-13 03:08:01 +02:00
Elijah
e2853a955c
test(runtime): support Windows in resolve_from_cwd_absolute (#18379)
`current_dir().unwrap()` joined with a Path is equivalent to the
implementation in `resolve_from_cwd()`. Manually tested on Ubuntu 22.04
and Windows 11.

Signed-off-by: Elijah Conners <business@elijahpepe.com>
2023-04-13 01:45:53 +02:00
Nayeem Rahman
d97f9d22b3
fix(test): add process sigint handler for --watch (#18678)
Fixes #18676.
2023-04-13 00:51:04 +02:00
David Sherret
17e4782140
fix(npm): eagerly reload package information when version from lockfile not found locally (#18673)
Closes #18624
2023-04-12 18:04:45 -04:00
David Sherret
9c255b2843
refactor: ProcState::build -> ProcState::from_flags (#18672) 2023-04-12 14:54:28 -04:00
denobot
05c393b99b
chore: forward v1.32.4 release commit to main (#18669)
Co-authored-by: levex <levex@users.noreply.github.com>
2023-04-12 13:03:27 -04:00
Luca Casonato
f90caa821c
refactor(ext/fs): abstract FS via FileSystem trait (#18599)
This commit abstracts out the specifics of the underlying system calls
FS operations behind a new `FileSystem` and `File` trait in the
`ext/fs` extension.

This allows other embedders to re-use ext/fs, but substituting in a
different FS backend.

This is likely not the final form of these traits. Eventually they will
be entirely `deno_core::Resource` agnostic, and will live in a seperate
crate.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-12 15:13:32 +02:00
David Sherret
0e3f62d444
fix(npm): cache bust npm specifiers more aggressively (#18636)
Part 1: #18622 
Part 2: This PR

Closes #16901

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-04-12 08:36:11 -04:00
Nayeem Rahman
806671af33
fix(core): preserve syntax error locations in dynamic imports (#18664)
Fixes #6259.

Adds the location for v8 syntax errors to the message (`message += " at
{location}"`) when rethrowing them for dynamic imports.

Discussing with @bartlomieju on discord I proposed just preserving v8's
error and not reconstructing it, allowing the standard stack trace to
just point to the syntax error instead of the dynamic import. But on
further thought this way has parity with SWC's syntax errors + has the
advantage of showing both the syntax error and dynamic import location.

```ts
// temp.js
await import("./temp2.js");

// temp2.js
function foo() {
  await Promise.resolve();
}

// Before:
// error: Uncaught (in promise) SyntaxError: Unexpected reserved word
// await import("./temp2.js");
// ^
//     at async file:///.../temp.js:1:1

// After:
// error: Uncaught (in promise) SyntaxError: Unexpected reserved word at file:///.../temp2.js:2:3
// await import("./temp2.js");
// ^
//     at async file:///.../temp.js:1:1
```
2023-04-12 13:45:36 +02:00
Satya Rohith
18e0ee368c
fix(ext/cache): cache.put overwrites previous call (#18649) 2023-04-12 11:25:19 +05:30