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

2626 commits

Author SHA1 Message Date
Leo Kettmeir
4cfc54931d
fix(node/http): allow callback in first argument of end call (#19778)
Closes #19762
2023-07-11 14:49:19 +02:00
David Sherret
be9e73d340
fix(lsp): remove quotes and period surrounding specifier in uncached messages (#19794) 2023-07-11 02:27:22 +00:00
David Sherret
0d8af65621
fix(lsp): exclude files in deno.json "exclude" (#19791)
Closes #19788
2023-07-10 21:03:19 -04:00
David Sherret
fe91cd5b84
chore(tests): update info_with_compiled_source to use TestContextBuilder (#19783) 2023-07-10 14:01:01 +00:00
Leo Kettmeir
5cda141f2d
fix(node/http): server use FakeSocket and add end method (#19660)
Fixes #19324
2023-07-10 13:48:35 +02:00
David Sherret
f3095b8d31
chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
Luca Casonato
679a0c428c
tests: add more jsxImportSource regression tests (#15592)
This commit adds some regression tests for using `jsxImportSource` in
the config file in combination with an import map.

These underlying issues were fixed by #15561.

Closes #13389
Closes #14723

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-07 01:22:22 +02:00
Yoshiya Hinosawa
cd2525d4cf
test(ext/node): clean up node:path test cases (#19610) 2023-07-05 16:13:34 +09:00
Bartek Iwańczuk
6d0c658023
fix: move Deno.serve to stable namespace (#19718)
This was missed in #19141
2023-07-04 23:04:26 +00:00
await-ovo
686ec85f52
fix(ext/node): Define performance.timeOrigin as getter property (#19714) 2023-07-04 20:19:18 +03:00
David Sherret
a3986b641c
fix: bump default @types/node version range to 18.16.19 (#19706) 2023-07-04 15:27:04 +00:00
Bartek Iwańczuk
39872646eb
feat: stabilize 'alpnProtocols' setting (#19704)
Ref https://github.com/denoland/deno/issues/19685
2023-07-04 15:28:50 +02:00
Bartek Iwańczuk
aaabff710f
tests: deflake _fs_read_test.ts again (#19705) 2023-07-04 02:43:04 +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
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
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
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
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
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
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
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
Kaique da Silva
4e01356586
test(ext/node): add fs open unit test from std (#19505) 2023-06-22 02:11:06 +09:00
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
Ryan Clements
d32287d211
fix(ext/node): remove fromFileUrl from "node:path" (#19504) 2023-06-16 19:43:59 +09: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
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
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
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
David Sherret
ff690b0ab4
chore: fix flaky stdio_streams_are_locked_in_permission_prompt (#19443) 2023-06-09 13:24:39 -04: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
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
8829a1d362
fix: upgrade to deno_ast 0.27 (#19375)
Closes #19148
2023-06-05 19:03:39 -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
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
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
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
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
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
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
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
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
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
2ebd61ee1b
fix(compile): handle when DENO_DIR is readonly (#19257)
Closes #19253
2023-05-25 14:27:45 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Kenta Moriuchi
74bb09aa38
fix(ext/url): throw TypeError for empty argument (#18896)
Fixes #18893
2023-04-30 12:24:34 +02: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
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
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
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
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
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
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
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
Kenta Moriuchi
9b49de4644
fix(core): Wrap safe collections' argument of primordials (#18750) 2023-04-26 00:36:22 +02:00
Yoshiya Hinosawa
63befe9377
fix(ext/node): fix hash.flush (#18818) 2023-04-25 11:21:26 +09: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
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
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
cf9fb18494
feat: upgrade deno_ast to 0.26 (#18795)
Closes #18792
2023-04-21 21:16:25 +00: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
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
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
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
David Sherret
1bca994143
chore: fix running node tests in parallel on Windows (#18711) 2023-04-14 18:50:58 -04:00
David Sherret
f6a28e3e62
chore: remove node_modules folder being created in testdata directory (#18708) 2023-04-14 21:56:14 +00: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
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
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
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
Levente Kurusa
65b0d2316d
refactor(node/crypto): port polyfill to Rust for randomInt, randomFill, randomFillSync (#18658)
Pretty much as per the title, I'd welcome some feedback especially
around the
array/buffer handling in the two randomFill functions.
2023-04-12 02:57:57 +02:00
David Sherret
8820f6e922
fix(npm): do not "npm install" when npm specifier happens to match package.json entry (#18660) 2023-04-11 18:10:51 -04:00
Geert-Jan Zwiers
805214626f
chore(cli): clean up unused number value (#18661)
This PR removes an accidentally declared number value.
2023-04-11 16:00:05 -04:00
Luca Casonato
e0bf8e6faf
fix(ext/kv): keys must be arrays (#18655)
There was some leftover code from previous iterations, where keys could
be single parts instead of arrays also. This didn't match the types.
2023-04-11 14:36:01 +00:00
Divy Srivastava
a0dd0cbcb9
fix(ext/node): add X509Certificate (#18625)
Towards #18455
2023-04-07 22:54:16 +05:30
David Sherret
5c7f76c570
fix(npm): reload an npm package's dependency's information when version not found (#18622)
This reloads an npm package's dependency's information when a
version/version req/tag is not found.

This PR applies only to dependencies of npm packages. It does NOT yet
cause npm specifiers to have their dependency information cache busted.
That requires a different solution, but this should help cache bust in
more scenarios.

Part of #16901, but doesn't close it yet
2023-04-06 21:41:19 -04:00
David Sherret
d07aa4a072
refactor(npm): use deno_npm and deno_semver (#18602) 2023-04-06 18:46:44 -04:00
David Sherret
1586c52b5b
chore: fix flaky tests checking ms when CI is slow (#18559) 2023-04-06 23:48:07 +02:00
Divy Srivastava
df72420d72
fix(ext/node): implement hkdf-expand (#18612)
Towards https://github.com/denoland/deno/issues/18455
2023-04-06 16:56:56 +00:00
Marvin Hagemeister
e51985ca74
fix(ext/node): fix unable to resolve fraction.js (#18544)
Turns out `autoprefixer` is a better reproduction case then
`microbundle`.

Fixes #18535 
Fixes #18600

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-06 16:12:50 +02:00
Divy Srivastava
3b62a58818
fix(ext/node): add symmetric keygen (#18609)
Towards #18455
2023-04-06 18:39:25 +05:30
Geert-Jan Zwiers
a7e25b8126
fix(ext/node): json encode binary command name (#18596)
Fixes https://github.com/denoland/deno/issues/18588
2023-04-06 01:46:21 +02:00
Bartek Iwańczuk
db39855fcb
tests: cleanup "node_compat_tests" (#18594)
A few drive-by cleanup while I'm working on the "crypto"
module. It makes it easier and faster to debug the failing
test case.
2023-04-05 13:15:57 +02:00
Bartek Iwańczuk
c4628aa809
refactor(ext/http): bring back 'reusePort' option for 'Deno.serve()' (#18590)
Closes https://github.com/denoland/deno/issues/18582
2023-04-04 14:17:36 +00:00
Kenta Moriuchi
2dc2016837
feat(ext/url): URL.canParse (#18286) 2023-04-04 13:34:12 +02:00
Bartek Iwańczuk
51d3fb78ad
refactor: remove "ext/flash" (#18578)
With https://github.com/denoland/deno/pull/18568 landed we no longer
need "ext/flash". 

This commit removes "deno_flash" extension completely.

This should have some impact on the binary and snapshot size.

Closes https://github.com/denoland/deno/issues/17356
2023-04-03 19:01:02 +02:00
Bartek Iwańczuk
2846bbe0a3
refactor: "Deno.serve()" API uses "Deno.serveHttp()" internally (#18568)
This commit changes implementation of "Deno.serve()" API to use
"Deno.serveHttp()" under the hood. This change will allow us to
remove the "flash" server implementation, bringing stability to the
"Deno.serve()" API.

"cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts".

Closes https://github.com/denoland/deno/issues/15574
Closes https://github.com/denoland/deno/issues/15504
Closes https://github.com/denoland/deno/issues/15646
Closes https://github.com/denoland/deno/issues/15909
Closes https://github.com/denoland/deno/issues/15911
Closes https://github.com/denoland/deno/issues/16828
Closes https://github.com/denoland/deno/issues/18046
Closes https://github.com/denoland/deno/issues/15869
2023-04-03 17:44:18 +02:00
Yoshiya Hinosawa
6d68392f8a
Revert "fix(cli): don't store blob and data urls in the module cache (#18261)" (#18572)
This reverts commit b4c61c146a.

cc @nayeemrmn
2023-04-03 21:05:39 +09:00
Nayeem Rahman
e5588d2f1e
fix(test): don't swallow sanitizer errors with permissions (#18550)
Missing `return` from #18246.
2023-04-01 16:20:16 -04:00