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

5191 commits

Author SHA1 Message Date
Bartek Iwańczuk
ae657731f7
chore: upgrade deno_lint to 0.49.0 (#19703) 2023-07-04 01:20:06 +00:00
Bartek Iwańczuk
cafbf0a7a1
tests: deflake _fs_read_test.ts (#19699)
Closes https://github.com/denoland/deno/issues/19632
2023-07-03 20:54:54 -04: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
David Sherret
7a7e0748e3
feat: upgrade to TypeScript 5.1.6 (#19695)
Integrates https://github.com/denoland/TypeScript/pull/7
2023-07-04 00:36:35 +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
David Sherret
e8a866ca8a
feat(lsp): support import maps in quick fix and auto-imports (#19692)
Closes https://github.com/denoland/vscode_deno/issues/849
Closes #15330
Closes #10951
Closes #13623
2023-07-03 14:09:24 -04:00
Bartek Iwańczuk
26c2abef7f
fix: Update typings for Deno.errors namespace (#19688)
Follow up to https://github.com/denoland/deno/pull/19514, where I forgot
to update type declarations.
2023-07-03 15:30:39 +02: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
Bartek Iwańczuk
0ddfd5d52a
test: ignore fmt_check_all_files_on_each_change_test (#19682)
Ref https://github.com/denoland/deno/issues/19629
2023-07-02 04:12:03 +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
Bartek Iwańczuk
bc381572d1
build: remove stale benchmark (#19681)
With https://github.com/denoland/deno/pull/19658 we can't bench it
anymore.
2023-07-02 03:24:54 +02:00
David Sherret
cfbc9b471f
feat(lsp): basic support of auto-imports for npm specifiers (#19675)
Closes #19625
Closes https://github.com/denoland/vscode_deno/issues/857
2023-07-02 01:07:57 +00:00
Matt Mastracci
e746b6d806
refactor(core): Extract deno_core (#19658)
`deno_core` is moving out! You'll find it at
https://github.com/denoland/deno_core/ once this PR lands.
2023-07-02 00:00:14 +00: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
David Sherret
dd508c9c89
fix(npm): support siblings that are peer dependencies of each other (#19657)
https://github.com/denoland/deno_npm/pull/20
2023-06-30 08:49:49 -04:00
Hans
aec761f755
test(ext/node): add perf_hooks test (#19648) 2023-06-30 16:46:48 +09:00
Kaique da Silva
9befc5cd48
test(ext/node): added unit test for net node modules compat from std (#19663) 2023-06-30 11:44:14 +09:00
Kaique da Silva
fc335bd28d
test(ext/node): added assertion errors test (#19609) 2023-06-30 11:22:04 +09:00
Leo Kettmeir
4db534d461
fix(node/http): add setKeepAlive to FakeSocket (#19659)
Closes #19535
2023-06-30 03:39:16 +02:00
scarf
09af1a5fef
fix: add exactOptionalPropertyTypes for configuration file JSON schema (#19647)
- fixes #19646 

lines copied from:
8513fdcc29/src/schemas/json/tsconfig.json (L281-L286)
2023-06-29 16:20:24 -04: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
Matt Mastracci
30f2cd3d1e
chore: reconfigure windows builder storage (#19601)
Use `C:` drive to build on Windows, as `D:` is too limited.
2023-06-28 13:41:47 -06:00
nasa
d82b5f3bec
fix(cli): Fix the bug where the command description is not displayed. (#19604) 2023-06-28 02:57:20 +02:00
Bartek Iwańczuk
6c6b20b9ea
chore: update deno_lint to 0.48.0 (#19619) 2023-06-27 12:01:20 +02:00
Heyang Zhou
805c922a5c
fix(kv): assertReject should always be awaited (#19612) 2023-06-27 16:41:29 +08:00
Felipe Baltor
814edcdd57
test(ext/node): port crypto_test.ts from deno_std (#19561) 2023-06-27 11:04:49 +09:00
David Sherret
a8d472f88e
feat(lock): skip saving declaration files in the lockfile (#19447)
This is also a performance improvement because declaration file hashes
don't need to be stored in the lockfile.

Closes #19444
2023-06-26 15:53:17 -04: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
Kaique da Silva
c7d38e593f
test(ext/node): add fs read unit tests (#19588) 2023-06-26 16:27:21 +09: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
7a8df8f00c
fix(cli): Don't use hardcoded port 4501 in serve test (#19599) 2023-06-24 13:55:08 +02:00
Bartek Iwańczuk
9273cbb786
bench: fix benchmarks (#19600) 2023-06-24 10:36:15 +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
Felipe Baltor
b319fa7f49
test(ext/node): port buffer_test.ts from deno_std (#19556) 2023-06-22 18:55:48 +09: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
Kaique da Silva
4e01356586
test(ext/node): add fs open unit test from std (#19505) 2023-06-22 02:11:06 +09:00
Dj
c9e478056f
fix(cli/napi): property with getter/setter always failed (#19562)
with `napi_define_properties`.
2023-06-21 07:43:23 +00:00
Dj
6729e9c977
fix(cli/napi): napi_get_buffer_info accepts ArrayBufferView … (#19551)
... not just `Uint8Array`.

This PR aligns behavior with Node.js Node-API implementation.
2023-06-21 13:11:58 +05:30
Felipe Baltor
544878cd2b
test(ext/node): port _fs_writeFile_test.ts from deno_std (#19524) 2023-06-19 18:52:25 +09:00
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
andy
faf6eaf2d3
chore: fix typos in HrtimePermissionDescriptor and performance.now docs (#19469) 2023-06-16 14:38:36 +02: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
Bartek Iwańczuk
0733943fe7
fix(cli): avoid crash on import of invalid module names (#19523)
Fixes https://github.com/denoland/deno/issues/17748
Closes #17770

Co-authored-by: Anton Bershanskiy
<bershanskiy@users.noreply.github.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-06-15 18:36:33 +00:00
David Sherret
fa63fd4610
refactor(flags): move watch flags into subcommand structs (#19516)
Moves the watch setting out of the `Flags` struct and into the
individual subcommands
2023-06-15 13:09:37 -04:00
Heyang Zhou
b2e546e530
chore(ext/kv): disable flaky test (#19522) 2023-06-15 18:53:36 +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
Matt Mastracci
3d71c36888
chore(ext/net): ignore startTls test (#19515) 2023-06-15 01:33:24 +00:00
Igor Zinkovsky
c71c497b1b
chore(kv) another fix for queue flaky test (#19513) 2023-06-14 16:27:59 -07:00
David Sherret
84c793275b
fix: reload config files on watcher restarts (#19487)
Closes #19468
2023-06-14 22:29:19 +00: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
Igor Zinkovsky
691ef2cc6a
chore(kv) fix flaky queue test (#19495) 2023-06-14 07:14:32 -07: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
David Sherret
82dd90f98d
chore: fix compile error on main (#19489) 2023-06-13 21:11:29 +00:00
David Sherret
015ea60d25
fix(lsp): don't pre-load documents matched in the config file's "exclude" (#19431)
This prevents documents specified in a deno.json's "exclude" from being
pre-loaded by the lsp.

For example, someone may have something like:

```jsonc
// deno.json
{
  "exclude": [
    "dist" // build directory
  ]
}
```
2023-06-13 15:48:53 -04:00
Leo Kettmeir
92e7287f4a
fix(node/buffer): make slice be the same as subarray (#19481) 2023-06-13 21:26:28 +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
David Sherret
5348778666
fix(npm): warn when tarball contains hardlink or symlink (#19474)
This is to help us get some visibility into whether we need to support
this.
2023-06-13 09:48:13 -04:00
David Sherret
3191ffdaaf
chore(repl): mark some tests as flaky (#19475) 2023-06-13 09:36:21 -04:00
David Sherret
39bf1d2fd5
fix(lsp): update import map config when deno.json changes (#19476)
Half of #19468
2023-06-13 09:24:22 -04: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
Kaique da Silva
44bd59c05e
test(ext/node): add fs dirent unit test from std (#19461)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-06-13 15:32:02 +09:00
Leo Kettmeir
b4ae37a617
feat(node): HTTPS server (#19362) 2023-06-13 04:15:08 +02:00
Matt Mastracci
45e15674b7
chore(core): fix flaky flock_test on windows (#19477) 2023-06-12 20:30:29 +00:00
Leo Kettmeir
e1be2bb80d
chore: update clap (#19467)
Also switches to use defer for all subcommands besides run.
2023-06-12 13:54:04 +02:00
David Sherret
7f15126f23
chore(tests): test_util - Add PathRef (#19450)
This adds a new `PathRef` struct to test_util for making it easier to
work with paths in test code. I'm going to expand on this more in the
future.
2023-06-10 11:09:45 -04:00
David Sherret
f99a849a5f
chore: fix flaky package_json_auto_discovered_for_local_script_arg (#19445) 2023-06-09 17:23:01 -04:00
Gustrb
2b2eebd583
perf(node): cache realpath_sync calls in read permission check (#19379) 2023-06-09 14:41:18 -04:00
David Sherret
ff690b0ab4
chore: fix flaky stdio_streams_are_locked_in_permission_prompt (#19443) 2023-06-09 13:24:39 -04:00
David Sherret
748a102919
fix(fmt): do not panic formatting json with multiple values (#19442) 2023-06-09 16:38:38 +00:00
David Sherret
5df735d3da
fix(config): do not canonicalize config file path before loading (#19436)
I'm unsure why we canonicalize the config file path when loading and the
canonicalization is causing issues in #19431 because everything in the
lsp is not canonicalized except the config file (actually, the config
file is only canonicalized when auto-discovered and not whens pecified).
We also don't canonicalize module paths when loading them.

Canonicalization was added in https://github.com/denoland/deno/pull/7621
2023-06-09 08:56:11 -04:00
Bartek Iwańczuk
168eb8e01d
perf: add Tokio runtime monitor (#19415)
This commit adds ability to print metrics of the Tokio
runtime to the console by passing "DENO_TOKIO_METRICS=1"
env var.

Metrics will be printed every second, but this can be changed
by "DENO_TOKIO_METRICS_INTERVAL=500" env var.
2023-06-09 11:52:51 +00: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
db9482d688
chore: Use relative paths for assert imports to avoid test flakes (#19427)
Tests occasionally fail if we get a bad gateway attempting to fetch the
assertion module
2023-06-08 18:10:37 +00:00
David Sherret
55f0150854
refactor(compile): store the npm snapshot in the eszip (#19343) 2023-06-08 11:48:29 -04: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
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
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
da9db887e3
refactor: helpers methods on TypeCheckMode (#19393) 2023-06-07 10:09:10 -04:00
Mike Mulchrone
28ce0ef583
fix(cli): formatting bench with colors (#19323) 2023-06-07 12:27:25 +02:00
David Sherret
2aba4365ae
perf(cli): conditionally load typescript declaration files (#19392)
Closes #18583
2023-06-06 17:07:46 -04:00
sigmaSd
455b0eb8bb
fix(repl): correctly print string exception (#19391)
Fixes a recent regression where `throw "hello"` in the repl prints
`Uncaught undefined` instead of `throw "hello"`
2023-06-06 23:06:30 +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
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
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
David Sherret
8829a1d362
fix: upgrade to deno_ast 0.27 (#19375)
Closes #19148
2023-06-05 19:03:39 -04:00
Kenta Moriuchi
d54ef02dfe
chore: update deno_lint to 0.46.0 (#19372) 2023-06-05 15:57:01 -04: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
Mathias Lafeldt
77a950aac4
feat(runtime): support creating workers using custom v8 params (#19339)
In order to limit the memory usage of isolates via heap_limits.
2023-06-05 09:22:32 +00: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
Nayeem Rahman
34dac6c6ef
refactor(core): remove force_op_registration and cleanup JsRuntimeForSnapshot (#19353)
Addresses
https://github.com/denoland/deno/pull/19308#discussion_r1212248194. 

Removes force_op_registration as it is no longer necessary.
2023-06-03 14:22:32 -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
Hirotaka Tagawa / wafuwafu13
0104741d6f
chore(node_compat): fix path strings generated by setup.ts (#19347) 2023-06-02 15:05:32 +09: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
Nayeem Rahman
befd03a3f0
refactor(core): don't pass op state to prepare_module_load() (#19332)
It's not used anymore. Subsequently allows removing
`ModuleMap::op_state`, allowing `ModuleMap` to have a sane default so
`JsRuntime::module_map` no longer needs to be optional.
2023-05-31 23:35:14 -06: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
Marvin Hagemeister
926d493f19
fix(runtime): add missing SIGIOT alias to SIGABRT (#19333) 2023-05-31 16:39:01 -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
Matt Mastracci
8e84dc0139
chore(core): Split JsRuntimeForSnapshot from JsRuntime (#19308)
This cleans up `JsRuntime` a bit more:

* We no longer print cargo's rerun-if-changed messages in `JsRuntime` --
those are printed elsewhere
* We no longer special case the OwnedIsolate for snapshots. Instead we
make use of an inner object that has the `Drop` impl and allows us to
`std::mem::forget` it if we need to extract the isolate for a snapshot
* The `snapshot` method is only available on `JsRuntimeForSnapshot`, not
`JsRuntime`.
* `OpState` construction is slightly cleaner, though I'd still like to
extract more

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-31 08:19:06 -06: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
David Sherret
42a3f52e98
fix: do not show cache initialization errors if stderr is piped (#18920)
Closes #18918
2023-05-30 13:35:02 -04:00
David Sherret
3b69d238cd
feat(runtime): add WorkerLogLevel (#19316)
This is not really used yet, but provides some infrastructure for doing
more fine grained logging in JS. I will add warn messages in a future
PR.
2023-05-30 15:34:50 +00: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
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
egg
fc6ba92024
test(ext/node): add os_test.ts (#19305)
Part of #17840

I haven't made any changes or additions to the tests themselves, just
moved the tests over and updated to match.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-29 15:03:14 +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
David Sherret
92080ff6f6
chore: maybe fix cli/standalone/virtual_fs tests on main (#19295)
Not sure why these don't fail on a PR run:
https://github.com/denoland/deno/actions/runs/5102317156/jobs/9171796164

**Merge on approval**
2023-05-28 15:55:30 +02:00
David Sherret
d43e75cbb2
chore: fix flaky test_include_dir_recursive (#19291)
Maybe fixes this on main.
2023-05-28 00:03:49 -04:00
David Sherret
a96844118c
fix(compile): inline symlinks as files outside node_modules dir and warn for directories (#19285)
If a symlink within the `node_modules` directory lies outside that
directory, it will now warn and inline the file. For directories, it
will just warn for now.

Probably fixes #19251 (I'm still unable to reproduce).
2023-05-27 10:33:15 -04: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
David Sherret
d0c5ff42f4
fix(compile): implicit read permission to npm vfs (#19281)
Closes #19280
2023-05-26 13:33:38 -04:00
Bartek Iwańczuk
d72e0281ff
chore: upgrade rusty_v8 to 0.73.0 (#19278) 2023-05-26 16:17:12 +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
d5a8a3d69f
chore: remove useless benchmark (#19272)
This benchmark is useless and only gives several hundred thousand
messages of failure.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-05-26 13:26:21 +00:00
David Sherret
25cbd97ab7
chore(lsp/tests): diagnostic synchronization (reland) (#19270)
Merge on approval as it fixes the flaky test.
2023-05-26 08:10:18 +02:00
Bartek Iwańczuk
e95f098ae3
fix(napi): properly handle arguments in napi_get_cb_info (#19269)
Closes https://github.com/denoland/deno/issues/17213
2023-05-26 05:02:12 +00: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
Bartek Iwańczuk
7ae55e75d8
Revert "chore(lsp/tests): diagnostic synchronization (#19264)" (#19268)
This reverts commit 89026abe39.

This change caused LSP benchmarks to fail on `main`.
2023-05-26 04:31:54 +00:00
David Sherret
89026abe39
chore(lsp/tests): diagnostic synchronization (#19264)
Fixes the flaky lsp test by having better synchronization of diagnostics
between the client and server for testing purposes.
2023-05-26 05:01:33 +02:00
David Sherret
2ddf85492f
fix(compile): improve panic message when stripping root path fails (#19258)
I'm not sure what's going on here, so this will help us debug.

For #19251
2023-05-25 15:29:58 -04:00
David Sherret
2ebd61ee1b
fix(compile): handle when DENO_DIR is readonly (#19257)
Closes #19253
2023-05-25 14:27:45 -04:00
Luca Casonato
76400149a4
fix: don't print release notes on version check prompt (#19252) 2023-05-25 14:45:11 +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
David Sherret
91ca9904b5
refactor: upgrade to deno_npm 0.6 (#19244) 2023-05-24 16:23:10 -04: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
David Sherret
ba6f573b4e
fix(npm): create node_modules/.deno/node_modules folder (#19242)
This is what pnpm does and we were missing it. It makes modules work
which have a dependency on something, but don't say they have that
dependency, but that dep is still in the tree somewhere.
2023-05-24 15:04:21 -04:00
Matt Mastracci
0fbfdaf901
chore(core): Ensure that net test ports aren't used elsewhere (#19243)
Fixes occasional test flake due to overlapping ports
2023-05-24 12:36:41 -06: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
e56695daa8
fix(napi): add napi_async_init and napi_async_destroy (#19234)
We don't have support for "AsyncContext" in "node:async_hooks" 
module, so these two APIs are just noops.

Towards https://github.com/denoland/deno/issues/18610.
2023-05-24 15:41:43 +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
David Sherret
cacc8c9a4d
feat: top level package.json install when node_modules dir is explicitly opted into (#19233)
When someone explicitly opts into using the node_modules dir via
`--node-modules-dir` or setting `"nodeModulesDir": true` in the
deno.json file, we should eagerly ensure a top level package.json
install is done on startup. This was initially always done when we added
package.json support and a package.json was auto-discovered, but scaled
it back to be lazily done when a bare specifier matched an entry in the
package.json because of how disruptive it was for people using Deno
scripts in Node projects. That said, it does not make sense for someone
to opt-into having deno control and use their node_modules directory and
not want a package.json install to occur. If such a rare scenario
exists, the `DENO_NO_PACKAGE_JSON=1` environment variable can be set.

Ideally, we would only ever use a node_modules directory with this
explicit opt-in so everything is very clear, but we still have this
automatic scenario when there's a package.json in order to make more
node projects work out of the box.
2023-05-23 18:51:48 -04:00
Bartek Iwańczuk
01a95d677f
chore: upgrade rusty_v8 to 0.72.0 (#19228)
This commit updates rusty_v8 to 0.72.0 and by extension
V8 to version 11.5.150.1.
2023-05-24 00:11:37 +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
Bartek Iwańczuk
3d865949c2
fix: better error message for malformed glob (#19225)
Before:
```
$ cargo run -- test "foo/*******/bar.ts"
error: Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**`
```

After:
```
$ cargo run -- test "foo/*******/bar.ts"
error: Failed to expand glob: "foo/*******/bar.ts"

Caused by:
    Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**`
```

---------

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-05-23 17:35:12 +00: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
Bartek Iwańczuk
5874fc3d0a
feat: add support for globs in the config file and CLI arguments for files (#19102)
Follow up to https://github.com/denoland/deno/pull/19084.

This commit adds support for globs in the configuration file as well 
as CLI arguments for files. 

With this change users can now use glob syntax for "include" and 
"exclude" fields, like so:

```json
{
  "lint": {
    "include": [
      "directory/test*.ts",
      "other_dir/"
    ],
    "exclude": [
      "other_dir/foo*.ts",
      "nested/nested2/*"
    ]
  },
  "test": {
    "include": [
      "data/test*.ts",
      "nested/",
      "tests/test[1-9].ts"
    ],
    "exclude": [
      "nested/foo?.ts",
      "nested/nested2/*"
    ]
  }
}
```

Or in CLI args like so:
```
// notice quotes here; these values will be passed to Deno verbatim
// and deno will perform glob expansion

$ deno fmt --ignore="data/*.ts"
$ deno lint "data/**/*.ts"
```

Closes https://github.com/denoland/deno/issues/17971
Closes https://github.com/denoland/deno/issues/6365
2023-05-23 03:39:59 +02:00
David Sherret
bb37dfb5b7
feat(lsp): support lockfile and node_modules directory (#19203)
This adds support for the lockfile and node_modules directory to the
lsp.

In the case of the node_modules directory, it is only enabled when
explicitly opted into via `"nodeModulesDir": true` in the configuration
file. This is to reduce the language server automatically modifying the
node_modules directory when the user doesn't want it to.

Closes #16510
Closes #16373
2023-05-22 21:28:36 -04:00
Leo Kettmeir
5878258952
refactor: further work on node http client (#19211) 2023-05-23 03:03:10 +02:00
David Sherret
7b4c483aa1
fix(npm): store npm binary command resolution in lockfile (#19219)
Part of #19038

Closes #19034 (eliminates the time spent re-resolving)
2023-05-22 16:55:04 -04:00
Matt Mastracci
612226de8e
chore(cli): One Rust test per JS and Node unit test file (#19199)
This runs our `js_unit_tests` and `node_unit_tests` in parallel, one
rust test per JS unit test file. Some of our JS tests don't like running
in parallel due to port requirements, so this also makes those use a
specific port-per-file. This does not attempt to make the node-compat
tests work.
2023-05-22 13:35:59 -06:00
Matt Mastracci
5c349039b8
chore(cli): Don't assume deno is in path for spawn_kill_permissions (#19198)
We don't need to use the `deno` command here to test kill permissions
and it's awkward to get right without passing `-A`. `cat` works, but for
platforms other than windows. This test should have plenty of coverage
on other platforms.
2023-05-22 09:54:58 -06:00
Connor Burton
19f1823e44
docs: be explicit in the unit of time of delay in setTimeout (#19207) 2023-05-22 14:04:28 +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
addfb0c546
fix(ci): simplify test assertion for http version enforcing with Deno.createHttpClient (#19210) 2023-05-21 21:52:45 +02:00
Leo Kettmeir
3e03865d89
feat(unstable): add more options to Deno.createHttpClient (#17385) 2023-05-21 03:43:54 +02:00
David Sherret
5664ac0b49
chore: add Deno version information to new 1.34 deno.json properties (#19202)
These already come up in the auto-complete, so let's let users know what
versions these are available in.
2023-05-19 23:35:24 +00:00
David Sherret
cc406c8360
feat(vendor): support for npm specifiers (#19186)
We never properly added support for this. This fixes vendoring when it
has npm or node specifiers. Vendoring occurs by adding a
`"nodeModulesDir": true` property to deno.json then it uses a local
node_modules directory. This can be opted out by setting
`"nodeModulesDir": false` or running with `--node-modules-dir=false`.

Closes #18090
Closes #17210
Closes #17619
Closes #16778
2023-05-19 22:39:27 +00: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
Bartek Iwańczuk
af72a9c657
Revert "perf: use jemalloc as global allocator (#18957)" (#19187)
This reverts commit 798c1ad0f1.

Reverting because this change caused a spike in memory usage, but we
can't fully realise gains from lower GC pressure from more optimal
malloc/ free provided by "jemalloc". 

We might revisit the topic in future.
2023-05-19 09:10:33 -04: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
David Sherret
c2995893be
feat(compile): remove need for --unstable with npm specifiers (#19185) 2023-05-19 01:26:49 +02:00
David Sherret
680ae31db8
feat(cli): add nodeModulesDir option to config file (#19095)
This adds an option to disable or enable using a local `node_modules`
directory as a project wide setting.

https://github.com/denoland/manual/pull/659

Closes #17930
2023-05-18 18:10:44 -04:00
scarf
a45f7f237b
feat(cli): top-level exclude field in deno.json (#17778) 2023-05-18 16:55:10 -04:00
David Sherret
55db691174
feat(task): glob expansion (#19084)
This adds cross-platform glob expansion to deno task.
2023-05-18 15:56:10 -04:00
Marvin Hagemeister
66d25df42c
fix(npm): run pre and post tasks if present (#19178)
This PR optionally runs pre and posts tasks from `package.json` if
available.

Fixes #19157
2023-05-18 15:51:17 -04: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
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
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
Bartek Iwańczuk
9dc3ae8523
fix(napi): BigInt related APIs (#19174)
Doesn't make the API bullet-proof and there are some TODOs left,
but greatly improves the situation. Tests were ported from Node.js.

Closes https://github.com/denoland/deno/issues/18276.
2023-05-18 12:49:56 +02:00
Bartek Iwańczuk
99c30285ff
chore: lint server_test.ts (#19175)
Somehow this file had `// deno-lint-ignore-file` directive at the top.

This commit removes it and fixes all the linter violations.
2023-05-18 02:00:17 +00:00
Matt Mastracci
62e779f82d
fix(runtime): Box the main future to avoid blowing up the stack (#19155)
This fixes `Unhandled exception at [...] Stack overflow` on Windows,
caused by the large size of the main future.
2023-05-17 15:49:57 -06:00
David Sherret
41f618a1df
fix(npm): improved optional dependency support (#19135)
Note: If the package information has already been cached, then this
requires running with `--reload` or for the registry information to be
fetched some other way (ex. the cache busting).

Closes #15544

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-17 17:38:50 -04:00
Yoshiya Hinosawa
243d9c846d
fix(ext/node): fix whatwg url formatting (#19146) 2023-05-17 14:51:51 +09:00
Heyang Zhou
320c6d30f5
fix(kv): kv.close() interrupts in-flight operations (#19076)
Fixes https://github.com/denoland/deno/issues/19049
2023-05-17 12:18:47 +08: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
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