Commit Graph

669 Commits

Author SHA1 Message Date
Nayeem Rahman
0a30897925
refactor(lsp): determine file referrer for each document (#23867) 2024-05-23 17:31:56 +01:00
David Sherret
143ea4759f
feat(task): run npm run commands with Deno more often (#23794)
Closes #23036
2024-05-23 15:39:48 +00:00
Bartek Iwańczuk
0b8deca08b
chore: update denokv_* crates (#23949)
Co-authored-by: losfair <zhy20000919@hotmail.com>
2024-05-23 16:35:16 +02:00
Divy Srivastava
aeafb7b39e
fix(ext/node): add stubs for perf_hooks.PerformaceObserver (#23958)
Fixes https://github.com/denoland/deno/issues/23943
2024-05-23 04:59:20 -07:00
Felipe Baltor
fa1ba256d2
refactor: remove custom utc_now in favor of chrono::Utc:now feature (#23888)
This PR removes the use of the custom `utc_now` function in favor of the
`chrono` implementation. It resolves #22864.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-23 13:59:11 +02:00
Milly
fa27350977
fix(ext/web): ReadableStream.from() ignores null Symbol.asyncIterator (#23910)
If `@@asyncIterator` is `null` or `undefined`, it should ignores and
fallback to `@@iterator`.

Tests have been merged into WPT.
https://github.com/web-platform-tests/wpt/pull/46374

The proposal of `ReadableStream.from` uses TC39 [GetIterator][] and
[GetMethod][] within it.
GetMethod treats null as undefined.
So if `@@asyncIterator` is `null` it should be ignored and fallback to
`@@iterator`.

[GetIterator]: https://tc39.es/ecma262/#sec-getiterator
[GetMethod]: https://tc39.es/ecma262/#sec-getmethod

```bash
> deno eval "ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream())"
error: Uncaught (in promise) TypeError: obj[SymbolAsyncIterator] is not a function
ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream())
               ^
    at getIterator (ext:deno_web/06_streams.js:5105:38)
    at Function.from (ext:deno_web/06_streams.js:5207:22)
    at file:///D:/work/js/deno/tests/wpt/suite/$deno$eval:1:16
```

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-05-23 13:55:07 +02:00
Matt Mastracci
b009c84bc6
feat: enable pointer compression via deno_core bump (#23838)
v8 12.6 w/pointer compression enabled.

Closes https://github.com/denoland/deno/issues/18935
2024-05-23 03:04:59 +00:00
Asher Gomez
71375491d1
feat(cli/test): deno test --clean (#23519)
The result of the call is ignored as it throws even when the directory
does not exist.

Closes #23491
2024-05-23 03:04:12 +00:00
Matt Mastracci
fab4c1776b
chore: kill node.js tests if they run too long (#23956) 2024-05-22 20:27:24 -06:00
Asher Gomez
8a636d0600
feat(ext/fetch): Request.bytes() and Response.bytes() (#23823)
Closes #23790
2024-05-23 00:27:58 +00:00
David Sherret
f5d0c4b1ea
feat: add lowercase -v version flag (#23750)
Ref https://github.com/denoland/deno/issues/5289
2024-05-23 00:20:20 +00:00
Luca Casonato
971f09abe4
fix(runtime): use more null proto objects (#23921)
This is a primordialization effort to improve resistance against users
tampering with the global `Object` prototype.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-23 00:03:35 +02:00
Hajime-san
cbddf468e3
fix(lsp): process Fenced Code Block in JSDoc on completion correctly (#23822)
partially fixing https://github.com/denoland/deno/issues/23820


https://github.com/denoland/deno/assets/41257923/0adb5d4e-cfd5-4195-9045-19d1c0a07a43

BTW, it is out of scope on this PR that to process type of `@param` to
be an code block due to it's a bit complicated.
2024-05-22 12:00:14 -07:00
Nathan Whitaker
466cc68afe
chore: Fix failing task_npx_non_existent test (#23945)
Currently `task::task_npx_non_existent` is consistently failing in CI
([example](https://github.com/denoland/deno/actions/runs/9192958846/job/25282900321#step:43:2772))
due to the output changing slightly

```
-- OUTPUT START --
Task non-existent npx this-command-should-not-exist-for-you
npm ERR! code E404
npm ERR! 404 Not Found - GET http://localhost:4260/this-command-should-not-exist-for-you
npm ERR! 404 
npm ERR! 404  'this-command-should-not-exist-for-you@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/runner/.npm/_logs/2024-05-22T17_58_42_473Z-debug-0.log

-- OUTPUT END --
-- EXPECTED START --
Task non-existent npx this-command-should-not-exist-for-you
npm error code E404
npm error 404 Not Found - GET http://localhost:4260/this-command-should-not-exist-for-you
[WILDCARD]

-- EXPECTED END --
```

I'm not sure what changed in CI to cause this (and I can't repro it
locally, even matching the version of npm and node on the github
runners), but fix it with more lenient expected output for that test.
2024-05-22 18:57:57 +00:00
David Sherret
f891d16493
chore(repl): maybe improve repl test flakiness on the CI (#23933)
These repl tests are still a bit flaky. Let's try this.

https://github.com/denoland/deno/actions/runs/9176525869/job/25232001263
2024-05-22 10:13:37 -04:00
Matt Mastracci
596a2996cf
feat(cli): Add slow test warning (#23874)
By default, uses a 60 second timeout, backing off 2x each time (can be
overridden using the hidden `DENO_SLOW_TEST_TIMEOUT` which we implement
only really for spec testing.

```
Deno.test(async function test() {
  await new Promise(r => setTimeout(r, 130_000));
});
```

```
$ target/debug/deno test /tmp/test_slow.ts 
Check file:///tmp/test_slow.ts
running 1 test from ../../../../../../tmp/test_slow.ts
test ...'test' is running very slowly (1m0s)
'test' is running very slowly (2m0s)
 ok (2m10s)

ok | 1 passed | 0 failed (2m10s)
```

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-22 08:08:27 -06:00
Leo Kettmeir
7ab7a14db7
refactor(docs): use @experimental instead of @tags unstable (#23884) 2024-05-22 04:31:51 -07:00
snek
8f2d171404
feat(node): buffer isUtf8/isAscii (#23928)
Fixes: https://github.com/denoland/deno/issues/23657

Implements `isUtf8` and `isAscii` as ops.
2024-05-21 15:50:59 -07:00
Nathan Whitaker
db82e8b557
fix(lsp): Fix display of JSDoc named examples (#23927)
We were wrapping the display string in an unnecessary pair of triple
backticks, breaking highlighting

Before:
![Screenshot 2024-05-21 at 12 16
12 PM](https://github.com/denoland/deno/assets/17734409/1cf5a3ce-56dd-443d-9d1a-bd33625ff1f2)

After:
![Screenshot 2024-05-21 at 12 16
36 PM](https://github.com/denoland/deno/assets/17734409/646c4c48-9b5a-4326-bb95-b1374627d969)
2024-05-21 14:04:19 -07:00
Kyle Kelley
8698e80304
refactor(jupyter): use runtimelib for Jupyter structures and directory paths (#23826)
This brings in [`runtimelib`](https://github.com/runtimed/runtimed) to
use:

## Fully typed structs for Jupyter Messages

```rust
let msg = connection.read().await?;

self
  .send_iopub(
    runtimelib::Status::busy().as_child_of(msg),
  )
  .await?;
```

## Jupyter paths

Jupyter paths are implemented in Rust, allowing the Deno kernel to be
installed completely via Deno without a requirement on Python or
Jupyter. Deno users will be able to install and use the kernel with just
VS Code or other editors that support Jupyter.

```rust
pub fn status() -> Result<(), AnyError> {
  let user_data_dir = user_data_dir()?;

  let kernel_spec_dir_path = user_data_dir.join("kernels").join("deno");
  let kernel_spec_path = kernel_spec_dir_path.join("kernel.json");

  if kernel_spec_path.exists() {
    log::info!(" Deno kernel already installed");
    Ok(())
  } else {
    log::warn!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up");
    Ok(())
  }
}
```

Closes https://github.com/denoland/deno/issues/21619
2024-05-21 22:35:21 +02:00
Nayeem Rahman
cc8c0609eb
fix(lsp): apply import fix to missing declaration code action (#23924) 2024-05-21 21:15:16 +01:00
David Sherret
ddb5449f42
chore: add test to ensure parsing only happens once on first load (#23837) 2024-05-21 16:12:40 -04:00
David Sherret
9795637724
fix(task): do not error if node_modules folder not exists (#23920)
Revealed https://github.com/denoland/deno/issues/23919

Closes #23914
2024-05-21 16:12:14 -04:00
Nayeem Rahman
a5111fbc4d
fix(cli): use CliNodeResolver::resolve() for managed node_modules (#23902) 2024-05-21 17:54:15 +01:00
David Sherret
3d6ba1eaf1
perf: analyze cjs re-exports in parallel (#23894) 2024-05-21 10:35:51 -04:00
Simon Lecoq
fa5c61e441
fix(cli/coverage): invalid line id in html reporter (#23908) 2024-05-21 13:37:36 +02:00
chirsz
529356cc12
fix(ext/webgpu): Allow depthClearValue to be undefined when depthLoadOp is not "clear" (#23850) 2024-05-20 13:47:04 -07:00
Marvin Hagemeister
eb97f110db
fix(node): stub findSourceMap for ava (#23899)
This stubs `findSourceMap` in `node:module` by always returning
`undefined` as if it never found a source map. This unblocks the `ava`
test runner.

Fixes https://github.com/denoland/deno/issues/18666
2024-05-20 16:42:42 +02:00
Marvin Hagemeister
fb3f82b9ea
fix(node): track SIG* listeners in process.listeners (#23890)
Some npm libraries like `signal-exit` rely on the length of the listener
array returned by `process.listeners("SIGNT")` to be correct to
function. We weren't tracking `SIG*` events there, which broke those npm
libraries.

Fixes https://github.com/denoland/deno/issues/22892
2024-05-20 15:24:13 +02:00
Marvin Hagemeister
d7709daaa0
fix(node): patch MessagePort in worker_thread message (#23871)
Our `MessagePort` to Node's `MessagePort` conversion logic was missing
the case where a `MessagePort` is sent _inside_ the message. This broke
`tinypool` which is used by `vitest` as it relies on some node specific
methods on `MessagePort`.

Fixes https://github.com/denoland/deno/issues/23854 , Fixes
https://github.com/denoland/deno/pull/23871
2024-05-20 15:01:40 +02:00
Bedis Nbiba
927cbb5ecd
fix: handle signal 0 in process.kill (#23473)
the last commit had a regression, where it removed this branch, I
haven't tested the code but I think it should work

---------

Signed-off-by: Bedis Nbiba <bedisnbiba@gmail.com>
2024-05-19 14:52:03 -04:00
David Sherret
a2dbcf9e0a
perf: analyze cjs exports and emit typescript in parallel (#23856) 2024-05-18 11:42:03 -04:00
Marvin Hagemeister
75efc74931
fix(node): instantiating process class without new (#23865)
Popular test runners like Jest instantiate a new `Process` object
themselves and expect the class constructor to be callable without the
`new` keyword. This PR refactors our `Process` class implementation from
a proper ES2015 class to an ES5-style class which can be invoked both
with and without the `new` keyword like in Node.

Fixes https://github.com/denoland/deno/issues/23863
2024-05-17 16:24:07 +02:00
Marvin Hagemeister
812f2e4c22
fix: serve handler error with 0 arguments (#23652)
Fixes https://github.com/denoland/deno/issues/23651

Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-05-17 18:05:19 +05:30
Satya Rohith
20cb0e8863
feat(serve): support --port 0 to use an open port (#23846)
Closes https://github.com/denoland/deno/issues/23845
2024-05-17 05:38:50 +00:00
Nayeem Rahman
f8956eb763
fix(lsp): respect types dependencies for tsc roots (#23825) 2024-05-16 22:12:25 +01:00
Divy Srivastava
88983fb3eb
fix(node): seperate worker module cache (#23634)
Construct a new module graph container for workers instead of sharing it
with the main worker.

Fixes #17248
Fixes #23461

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-05-16 07:09:35 +00:00
Divy Srivastava
bba553bea5
fix(ext/node): homedir() getpwuid/SHGetKnownFolderPath fallback (#23841)
**Unix**: Returns the value of the HOME environment variable if it is
set even if it is an empty string. Otherwise, it tries to determine the
home directory by invoking the
[getpwuid_r](https://linux.die.net/man/3/getpwuid_r) function with the
UID of the current user.

**Windows**: Returns the value of the USERPROFILE environment variable
if it is set and it is not an empty string. Otherwise, it tries to
determine the home directory by invoking the
[SHGetKnownFolderPath](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath)
function with
[FOLDERID_Profile](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid).

Fixes https://github.com/denoland/deno/issues/23824
2024-05-16 10:52:40 +05:30
Divy Srivastava
a31b81394b
fix(ext/node): export geteuid from node:process (#23840)
Fixes https://github.com/denoland/deno/issues/23827
2024-05-16 10:32:11 +05:30
David Sherret
5385a42ec4
perf(jsr): download metadata files as soon as possible and in parallel (#23836)
* https://github.com/denoland/deno_graph/pull/471
* https://github.com/denoland/deno_graph/pull/473
2024-05-16 00:58:57 +02:00
Nathan Whitaker
3cea44abde
chore: Fix flaky semantic tokens caching test (#23831)
The stderr stream from the LSP is consumed by a separate thread, so it
may not have processed the part we care about yet. Instead, wait until
you see the measure for the request you care about.
2024-05-15 11:38:45 -07:00
Marvin Hagemeister
e02d0faedc
fix(node): wrong worker_threads.terminate() return value (#23803)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

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

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

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

Fixes https://github.com/denoland/deno/issues/23801

---------

Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-15 17:08:25 +02:00
David Sherret
e661591e7c
chore: fix flaky '[node/http] send request with non-chunked body' test (#23818)
https://github.com/denoland/deno/actions/runs/9086887959/job/24973565321
2024-05-15 08:37:46 -04:00
Nathan Whitaker
36d877be4a
perf(lsp): Cache semantic tokens for open documents (#23799)
VScode will typically send a `textDocument/semanticTokens/full` request
followed by `textDocument/semanticTokens/range`, and occassionally
request semantic tokens even when we know nothing has changed. Semantic
tokens also get refreshed on each change. Computing semantic tokens is
relatively heavy in TSC, so we should avoid it as much as possible.

Caches the semantic tokens for open documents, to avoid making TSC do
unnecessary work. Results in a noticeable improvement in local
benchmarking

before:
```
Starting Deno benchmark
-> Start benchmarking lsp
   - Simple Startup/Shutdown 
      (10 runs, mean: 383ms)
   - Big Document/Several Edits 
      (5 runs, mean: 1079ms)
   - Find/Replace
      (10 runs, mean: 59ms)
   - Code Lens
      (10 runs, mean: 440ms)
   - deco-cx/apps Multiple Edits + Navigation
      (5 runs, mean: 9921ms)
<- End benchmarking lsp
```

after:
```
Starting Deno benchmark
-> Start benchmarking lsp
   - Simple Startup/Shutdown 
      (10 runs, mean: 395ms)
   - Big Document/Several Edits 
      (5 runs, mean: 1024ms)
   - Find/Replace
      (10 runs, mean: 56ms)
   - Code Lens
      (10 runs, mean: 438ms)
   - deco-cx/apps Multiple Edits + Navigation
      (5 runs, mean: 8927ms)
<- End benchmarking lsp
```
2024-05-15 01:51:48 +00:00
David Sherret
1a788b58a0
chore: fix flaky rejection_handled_web_process (#23817)
Closes https://github.com/denoland/deno/issues/23712
2024-05-14 23:51:51 +00:00
Marvin Hagemeister
e389917535
fix(node): stub AsyncResource.emitDestroy() (#23802)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

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

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

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

Fixes https://github.com/denoland/deno/issues/23397
2024-05-15 00:42:43 +02:00
David Sherret
4ddc85e1da
fix(emit): regression - keep comments in emit (#23815)
Closes https://github.com/denoland/deno/discussions/23814
2024-05-14 22:01:31 +00:00
Nayeem Rahman
dda8979cb1
fix(lsp): show reference code lens on methods (#23804) 2024-05-14 22:42:35 +01:00
David Sherret
1e2b0a2219
chore(tests): increase repl timeout on ci (#23812)
https://github.com/denoland/deno/actions/runs/9084225162/job/24964698935

```
---- run::file_fetcher_preserves_permissions stdout ----
command /Users/runner/work/deno/deno/target/debug/deno repl --quiet
command cwd /Users/runner/work/deno/deno/tests/testdata
------ Start Full Text ------
"const a = await import('http://localhost:4545/run/019_media_types.ts');\r\n"
------- End Full Text -------
Next text: "\r\n"
thread 'run::file_fetcher_preserves_permissions' panicked at tests/integration/run_tests.rs:4615:15:
Timed out.
```

Closes https://github.com/denoland/deno/issues/23690
Closes https://github.com/denoland/deno/issues/23682
Closes https://github.com/denoland/deno/issues/23625
2024-05-14 15:59:32 -04:00
David Sherret
c0e3b6ed9d
fix(publish): always include config file when publishing (#23797)
Closes https://github.com/denoland/deno/issues/23796
2024-05-14 18:15:43 +00:00
David Sherret
432792a46c
chore: 045_proxy output stdout & stderr on failure (#23810)
Part of https://github.com/denoland/deno/issues/23624
2024-05-14 16:47:57 +00:00
David Sherret
c6189e2070
fix(publish): error for missing version constraints on dry-publish instead of just publish (#23798)
Closes https://github.com/denoland/deno/issues/22835
2024-05-14 10:30:09 -04:00
futsuuu
c0a600786e
fix: Add missing "junction" type for SymlinkOptions.types (#23756)
Junction symlink support is added in #22762, but `SymlinkOptions` and
its documents are not updated.
2024-05-14 15:06:21 +02:00
Mattias Buelens
9338770a70
fix(ext/web): update ongoing promise in async iterator return() method (#23642)
See https://github.com/whatwg/webidl/pull/1387 for context.

There are new WPT tests for this change in
https://github.com/web-platform-tests/wpt/pull/44456. They pass on my
local machine, but I'm not sure if I should update the WPT submodule for
all of Deno as part of this PR?

Fixes #22389

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.
2024-05-13 23:34:25 +00:00
David Sherret
f2dc3f9a94
chore(task): various small refactorings (#23793) 2024-05-13 22:55:14 +00:00
Leo Kettmeir
df879f9f74
chore: cleanup unused dependencies (#23787) 2024-05-13 14:23:39 -07:00
Evan
329a8ae0c0
fix(cli): panic with deno coverage (#23353)
This PR directly addresses the issue raised in #23282 where Deno panics
if `deno coverage` is called with `--include` regex that returns no
matches.

I've opted not to change the return value of `collect_summary` for
simplicity and return an empty `HashMap` instead
2024-05-13 23:18:38 +02:00
Bartek Iwańczuk
03a76f33ad
fix(ext/node): process.uptime works without this (#23786)
Fixes https://github.com/denoland/deno/issues/23761

Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-05-12 23:38:22 +00:00
David Sherret
2b62a5b814
fix(npm): handle null fields in npm registry JSON (#23785)
* https://github.com/denoland/deno_npm/pull/52

Closes https://github.com/denoland/deno/issues/23776
2024-05-12 22:19:04 +00:00
Matt Mastracci
adc7b3de26
fix(runtime): Allow opening /dev/fd/XXX for unix (#23743)
`deno run script.ts <(some command)` is a valid use case -- let's allow
this to work without `--allow-all`.

Fixes #23703
2024-05-10 11:21:36 -06:00
David Sherret
a9708037c9
fix(node): better cjs re-export handling (#23760)
Closes #23458
2024-05-10 09:55:20 -04:00
Leo Kettmeir
6066e069d1
fix(ext/webgpu): invalidate GPUAdapter when a device is created (#23752)
This removes the need for using `Deno.resources` to close the gpuadapter
resource, while being more spec compliant.
2024-05-10 04:10:22 -07:00
Nathan Whitaker
19c0633a94
refactor(lsp): Have JS drive TSC event loop in LSP (#23565) 2024-05-09 13:49:10 -07:00
David Sherret
f0e8ec0146
fix(lsp): completions for using decl identifiers (#23748)
Closes #23688
2024-05-09 13:18:13 -04:00
Matt Mastracci
684377c92c
refactor(ext/tls): Implement required functionality for later SNI support (#23686)
Precursor to #23236 

This implements the SNI features, but uses private symbols to avoid
exposing the functionality at this time. Note that to properly test this
feature, we need to add a way for `connectTls` to specify a hostname.
This is something that should be pushed into that API at a later time as
well.

```ts
Deno.test(
  { permissions: { net: true, read: true } },
  async function listenResolver() {
    let sniRequests = [];
    const listener = Deno.listenTls({
      hostname: "localhost",
      port: 0,
      [resolverSymbol]: (sni: string) => {
        sniRequests.push(sni);
        return {
          cert,
          key,
        };
      },
    });

    {
      const conn = await Deno.connectTls({
        hostname: "localhost",
        [serverNameSymbol]: "server-1",
        port: listener.addr.port,
      });
      const [_handshake, serverConn] = await Promise.all([
        conn.handshake(),
        listener.accept(),
      ]);
      conn.close();
      serverConn.close();
    }

    {
      const conn = await Deno.connectTls({
        hostname: "localhost",
        [serverNameSymbol]: "server-2",
        port: listener.addr.port,
      });
      const [_handshake, serverConn] = await Promise.all([
        conn.handshake(),
        listener.accept(),
      ]);
      conn.close();
      serverConn.close();
    }

    assertEquals(sniRequests, ["server-1", "server-2"]);
    listener.close();
  },
);
```

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-05-09 10:54:47 -06:00
Nathan Whitaker
dc29986ae5
fix(lsp): move sloppy import resolution from loader to resolver (#23751)
Moves sloppy import resolution from the loader to the resolver.

Also adds some test helper functions to make the lsp tests less verbose

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-05-09 14:17:31 +00:00
David Sherret
263b6b971d
fix(task): regression where npx <command> sometimes couldn't find command (#23730)
Closes https://github.com/denoland/deno/issues/23724
2024-05-09 03:16:44 +00:00
David Sherret
47f7bed677
chore: enable clippy::print_stdout and clippy::print_stderr (#23732)
1. Generally we should prefer to use the `log` crate.
2. I very often accidentally commit `eprintln`s.

When we should use `println` or `eprintln`, it's not too bad to be a bit
more verbose and ignore the lint rule.
2024-05-08 22:45:06 -04:00
Matt Mastracci
9f7f681e26
fix(runtime): allow nul device on windows (#23741)
Fixes [23721](https://github.com/denoland/deno/issues/23721)
2024-05-08 14:39:06 -06:00
David Sherret
547ce6c3b8
chore: cleanup some coverage tests (#23738) 2024-05-08 16:07:56 -04:00
Bartek Iwańczuk
4e23a5b1fc
FUTURE: deno install changes (#23498)
This PR implements the changes we plan to make to `deno install` in deno
2.0.
- `deno install` without arguments caches dependencies from
`package.json` / `deno.json` and sets up the `node_modules` folder
- `deno install <pkg>` adds the package to the config file (either
`package.json` or `deno.json`), i.e. it aliases `deno add`
- `deno add` can also add deps to `package.json` (this is gated behind
`DENO_FUTURE` due to uncertainty around handling projects with both
`deno.json` and `package.json`)
- `deno install -g <bin>` installs a package as a globally available
binary (the same as `deno install <bin>` in 1.0)

---------

Co-authored-by: Nathan Whitaker <nathan@deno.com>
2024-05-08 12:34:46 -07:00
David Sherret
525b3c8d74
fix: upgrade TypeScript from 5.4.3 to 5.4.5 (#23740)
https://github.com/denoland/TypeScript/pull/11
2024-05-08 13:54:56 -04:00
David Sherret
5379bb0289
fix(jsr): panic when importing jsr package with deps via https (#23728)
Closes #23644
2024-05-07 21:53:17 +00:00
Bartek Iwańczuk
25fcfe5d79
fix: DOMException doesn't throw on __callSitesEvals (#23729) 2024-05-07 21:02:29 +00:00
David Sherret
998036b399
chore: fix flaky net_listen_allow_localhost_4555 (#23726)
Moves the test npm registry server port from `4558` to `426x`
2024-05-07 17:21:56 +00:00
Luca Casonato
f3cc760f2f
fix(runtime): allow r/w access to /etc without --allow-all (#23718)
This is not a special path that can be used to escalate or bypass Deno
permissions, such as `--allow-env`.
2024-05-07 14:51:42 +02:00
Hajime-san
e7a2317f5a
fix(ext/web): properly handle Blob case for createImageBitmap (#23518)
fixes https://github.com/denoland/deno/issues/22649
2024-05-07 04:47:42 -07:00
David Sherret
1587387bcc
chore(test): move npm registries to separate servers and to the tests/registry folder (#23717)
1. Moves the npm registries to their own dedicated ports.
2. Moves the data files out of `tests/testdata/npm/registry` to
`tests/registry/npm`.
2024-05-07 01:06:01 +00:00
Nathan Whitaker
672216d65a
fix(lsp): Pass diagnostic codes to TSC as numbers (#23720)
Fixes the `Debug Failure` errors described in
https://github.com/denoland/deno/issues/23643#issuecomment-2094552765 .

The issue here was that we were passing diagnostic codes as strings but
TSC expects the codes to be numbers. This resulted in some quick fixes
not working (as illustrated by the test added here which fails before
this PR).

The first commit is the actual fix. The rest are just test related.
2024-05-06 23:54:52 +00:00
Nathan Whitaker
8eb1f11112
chore: (Hopefully) make jupyter_execute_request test less flaky (#23689)
A bunch of small things, mostly around timing and making sure the
jupyter kernel is actually running and ready to respond to requests. I
reproduced the flakiness by running a script to run a bunch of instances
of the test in parallel, where I could get failures consistently. After
this PR, I can't reproduce the flakiness locally which hopefully means
that applies to CI as well
2024-05-06 23:32:22 +00:00
David Sherret
2dcbef2abb
fix(compile): relative permissions should be retained as relative (#23719)
Closes #23715
2024-05-06 19:21:58 -04:00
Bartek Iwańczuk
f698bc70e2
fix(ext/node): napi_get_element and napi_set_element work with objects (#23713)
This change makes DuckDB example work:
https://github.com/denoland/deno/issues/23656.
2024-05-06 21:22:50 +02:00
Hajime-san
a635abbf21
fix(ext/webgpu): correctly validate GPUExtent3D, GPUOrigin3D, GPUOrigin2D & GPUColor (#23413) 2024-05-06 06:26:25 -07:00
Jo Franchetti
a69b4646a0
docs: update categories to match new planned sitemap (#23677)
Updating categories for new sitemap as documented here:

https://lucid.app/lucidspark/744b0498-a133-494d-981c-76059dd18885/edit?view_items=jpvBwFdYlNdB&invitationId=inv_50c83415-2aa5-423f-b438-ea156695c08b
2024-05-05 18:56:55 -07:00
David Sherret
397be1a22c
chore: maybe make fmt_check_all_files_on_each_change_test less flaky (#23704)
https://github.com/denoland/deno/actions/runs/8958830735/job/24603538912
2024-05-05 18:09:45 -04:00
Leo Kettmeir
cd12d41627
chore: update wgpu (#23684) 2024-05-05 07:22:18 -07:00
David Sherret
d81e97f92f
chore: maybe make watcher tests less flaky (#23683)
Closes #23637
2024-05-03 17:31:12 -04:00
David Sherret
121769844d
fix(lsp): always cache all npm packages (#23679)
Closes #23659
2024-05-03 16:44:41 -04:00
Nayeem Rahman
1fce59281c
refactor(lsp): cleanup cache and module registry update (#23620) 2024-05-03 20:52:58 +01:00
Satya Rohith
02d0ff58d2
refactor(tests): move worker_threads itests to spec tests (#23648) 2024-05-03 05:52:47 +00:00
David Sherret
3e98ea4e69
chore(tests/specs): ability to have sub tests in file (#23667)
Allows writing named sub-tests. These are:

1. Filterable on the command line via `cargo test ...`
2. Run in parallel
3. Use a fresh temp and deno dir for each test (unlike steps)
2024-05-03 10:19:42 +05:30
David Sherret
b7945a218e
chore: move cert itests to spec tests (#23607) 2024-05-03 00:43:12 +00:00
Bartek Iwańczuk
cf0579c7d4
test: npm registry handles two test scopes (#23663)
This commit updates our testing npm registry to handle
additional `@denotest2` scope in addition to `@denotest`
scope. I might have to update it further in the future to handle
additional scopes, but it's good enough for now.
2024-05-03 00:00:38 +00:00
Leo Kettmeir
1b27b58396
fix(test): proper type checking for files with doc tests (#23654)
Closes https://github.com/denoland/deno/issues/23430

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2024-05-02 18:13:51 +00:00
Satya Rohith
56ba7f3c23
fix(ext/node): support delete process.env.var (#23647)
Closes https://github.com/denoland/deno/issues/23641
2024-05-02 06:40:22 +00:00
Matt Mastracci
505130d813
chore(cli): add permission test (#23633) 2024-05-01 13:17:05 -06:00
David Sherret
e0069c87c0
chore: make a couple repl tests less flaky (#23636)
These were both failing for me from time to time locally.
2024-05-01 16:37:17 +00:00
David Sherret
56bf634fa9
fix(node): require.resolve - fallback to global cache when bare specifier from paths not found (#23618)
Part of #22607 (probably closes it, but I haven't done thorough testing)

Makes it so that `require.resolve` with `paths` specified will fallback
to using the global cache when the paths can't be found when using a
global cache (not when using a node_modules folder)
2024-04-30 23:41:29 -04:00
David Sherret
f2216c90a7
chore: fix flaky module graph cache tests (#23623) 2024-05-01 01:36:52 +00:00
Nayeem Rahman
ac9e07bdfa
chore(lsp): revert import map pre-resolution for jsxImportSource (#23619) 2024-05-01 01:44:20 +01:00
Luca Casonato
6cdf81db7c
feat(cli): add support for jsxImportSourceTypes (#23419)
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-04-30 18:12:35 +00:00
Satya Rohith
0156f82e73
fix(ext/node): support multiple message listeners on MessagePort (#23600)
Closes https://github.com/denoland/deno/issues/23561
2024-04-30 16:59:39 +05:30
Kenta Moriuchi
783533d2e3
FUTURE: remove import assertions support for JavaScript (#23541)
Ref #17944, https://github.com/swc-project/swc/issues/8893

TypeScript removes the `assert` keywords in the transpile, so this PR
only works for JavaScript files
2024-04-29 22:43:05 +02:00
David Sherret
4384a126bb
fix: handle specifying an import map in an ancestor dir of deno.json (#23602)
* https://github.com/denoland/deno_config/pull/51

Closes https://github.com/denoland/deno/issues/21440
2024-04-29 14:32:27 -04:00
David Sherret
48daf2dc88
chore: add tests for moduleGraph2 (#23603)
Also did some renames from underscores to hyphens
2024-04-29 14:09:58 -04:00
Matt Mastracci
56fec538e1
fix(ext/http): ensure signal is created iff requested (#23601)
This correctly creates the `AbortSignal` regardless of when we request
it. If the signal is requested after the request has completed, the
signal is created in the aborted state.

Using GC counts, we can see a reduction in object creation:

This PR: 440
deno 1.42.4: 1650
deno 1.43.0+b02ffec: 874
2024-04-29 09:40:02 -06:00
David Sherret
da52058a94
chore: migrate bench, publish, and more itests to spec tests (#23584) 2024-04-29 10:08:27 -04:00
Divy Srivastava
b02ffec37c
fix(ext/node): exporting rsa public keys (#23596)
Initial support for exporting rsa public KeyObject.

Current assumption is that RSA keys are stored in pkcs1 der format in
key storage.

Ref https://github.com/denoland/deno/issues/23471 
Ref https://github.com/denoland/deno/issues/18928
Ref https://github.com/denoland/deno/issues/21124
2024-04-29 19:16:38 +05:30
Satya Rohith
b8444066ea
fix(ext/node): support NODE_DEBUG env (#23583) 2024-04-29 09:36:53 +00:00
Satya Rohith
455cf1743f
fix(ext/node): add support for MessagePort.removeListener/off (#23598)
Closes https://github.com/denoland/deno/issues/23564
2024-04-29 08:53:54 +00:00
David Sherret
651e3e9e6d
fix(compile): certain jsr specifiers sometimes can't load (#23567)
When returning a jsr specifier for resolve it seems like deno core does
not work properly and hangs.

Closes https://github.com/denoland/deno/issues/23551
Closes https://github.com/denoland/deno/issues/23139
2024-04-27 21:11:57 +00:00
Yoshiya Hinosawa
8178f758bc
fix(ext/node): support process.stdin.unref() (#22865)
This PR adds private `[REF]()` and `[UNREF]()` methods to Stdin class,
and call them from Node.js polyfill layer (`TTY` class). This enables
`process.stdin.unref()` and `process.stdin.ref()` for the case when
stdin is terminal.

closes #21796
2024-04-27 20:25:18 +09:00
Bartek Iwańczuk
e3d79c1703
test: cleanup npm test registry code (#23578)
Required for https://github.com/denoland/deno/pull/23560
2024-04-26 22:55:43 +02:00
Leo Kettmeir
c519355624
feat(ci): category & unstable tags checker (#23568) 2024-04-26 09:04:29 -07:00
Bartek Iwańczuk
0b0af5c635
test: update for private npm registry test server (#23572)
Factored out from https://github.com/denoland/deno/pull/23560 to make it
easier to review.
2024-04-26 15:41:53 +00:00
Matt Mastracci
8c9caeb418
chore: rework TLS code in test server (#23566)
In order to make the reqwest/rustls upgrade more straightforward, we
refactor the test server to depend on deno_tls.
2024-04-25 17:00:04 -04:00
Bartek Iwańczuk
115dedde22
fix: unref stdin read (#23534)
Closes https://github.com/denoland/deno_core/issues/648

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-04-25 05:32:01 +00:00
David Sherret
f3284529f1
feat(jsr): support importing from jsr via HTTPS specifiers (except for type checking) (#23513)
Closes https://github.com/jsr-io/jsr/issues/322
2024-04-24 21:43:34 +00:00
Leo Kettmeir
5a7414e163
chore: update deno_doc (#23544) 2024-04-24 20:34:21 +00:00
Nayeem Rahman
ac71d876d7
fix(lsp): inherit missing fmt and lint config from parent scopes (#23547) 2024-04-24 22:14:01 +02:00
Matt Mastracci
2f8825a935
feat: Add deno serve subcommand (#23511)
By default, `deno serve` will assign port 8000 (like `Deno.serve`).
Users may choose a different port using `--port`.

`deno serve /tmp/file.ts`

`server.ts`:
```ts
export default {
  fetch(req) {
    return new Response("hello world!\n");
  },
};
```
2024-04-24 19:45:49 +00:00
David Sherret
ded6afccf2
fix(publish): --dry-publish should error for gitignored excluded files (#23540)
Files that were gitignored only were not included in the diagnostic.
2024-04-24 18:52:05 +00:00
Matt Mastracci
da70608700
fix(ext/net): check for TLS using undefined rather than using ReflectHas (#23538)
Fixes #23537
2024-04-24 14:27:15 -04:00
Matt Mastracci
eed2598e6c
feat(ext/http): Implement request.signal for Deno.serve (#23425)
When the response has been successfully send, we abort the
`Request.signal` property to indicate that all resources associated with
this transaction may be torn down.
2024-04-24 14:03:37 -04:00
Matt Mastracci
b60822f6e0
chore: use deno_unsync through deno_core (#23532) 2024-04-24 16:57:34 +00:00
Bartek Iwańczuk
b424959d3e
fix(ext/node): worker_threads copies env object (#23536)
Most common argument to `env` option for `worker_threads.Worker` will be
`process.env`.

In Deno `process.env` is a `Proxy` which can't be cloned using
structured clone algorithm.

So to be safe, I'm creating a copy of actual object before it's sent to
the worker thread.

Ref #23522
2024-04-24 16:17:28 +00:00
Bartek Iwańczuk
90a167a1a2
test: add private npm registry (#23510)
This commit adds a "private npm registry" to the test server. This
registry requires to send an appropriate Authorization header.

Towards https://github.com/denoland/deno/issues/16105
2024-04-23 22:54:34 +02:00
Kenta Moriuchi
aff7a64544
fix: Float16Array support (#23512)
Ref #23490, #23277

* remove `--js-float16array` flag (This flag has already added to
deno_core)
* add some `Float16Array` support
2024-04-23 22:54:19 +02:00
Nathan Whitaker
8a367d3cc3
fix(cli): Don't panic on invalid emit options (#23463)
Fixes #23456.
2024-04-23 08:50:50 -07:00
Bartek Iwańczuk
35220f0069
fix(workspace): provide workspace members as 'imports' in import map (#23492)
This commit changes the workspace support to provide all workspace
members to be available as imports based on their names and versions.

Closes https://github.com/denoland/deno/issues/23343
2024-04-23 17:21:06 +02:00
Bartek Iwańczuk
b0d3b20f23
feat: enable Float16Array support (#23490)
Closes https://github.com/denoland/deno/issues/23450
2024-04-23 15:18:27 +00:00
Nayeem Rahman
5990f05360
fix(lsp): remove Document::open_data on close (#23483) 2024-04-22 19:24:00 +01:00
Marvin Hagemeister
9686a8803e
feat: add jsx precompile skip element option (#23457)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/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.
-->
This PR wires up a new `jsxPrecompileSkipElements` option in
`compilerOptions` that can be used to exempt a list of elements from
being precompiled with the `precompile` JSX transform.
2024-04-22 17:07:36 +02:00
Nathan Whitaker
aac7a8cb7c
perf(lsp): Batch "$projectChanged" notification in with the next JS request (#23451)
The actual handling of `$projectChanged` is quick, but JS requests are
not. The cleared caches only get repopulated on the next actual request,
so just batch the change notification in with the next actual request.

No significant difference in benchmarks on my machine, but this speeds
up `did_change` handling and reduces our total number of JS requests (in
addition to coalescing multiple JS change notifs into one).
2024-04-22 08:03:16 -07:00
Asher Gomez
2f5a6a8514
FUTURE(ext/net): remove Deno.ConnectTlsOptions.(certFile|certChain|privateKey) (#23270)
Towards #23089

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-04-21 03:03:44 +00:00
Bartek Iwańczuk
14ae4f897f
fix(ext/node): define http.maxHeaderSize (#23479)
Closes https://github.com/denoland/deno/issues/23432
2024-04-21 07:31:23 +05:30
Asher Gomez
98e2f6d50b
FUTURE(ext/net): remove Deno.ListenTlsOptions.(keyFile|certFile) (#23271)
Towards #23089

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-04-21 01:58:59 +00:00
David Sherret
695f314a91
feat(task): support running npm binary commands in deno.json (#23478)
npm binary commands like `vite` from a `node_modules/.bin` folder will
now execute when defined in a deno.json

Closes https://github.com/denoland/deno/issues/23477
2024-04-20 20:13:46 -04:00
welfuture
e55087f57a
fix: Fix some typos in comments (#23470)
Signed-off-by: welfuture <wellfuture@qq.com>
2024-04-21 01:54:07 +02:00
David Sherret
db3b3fb665
chore: auto-complete for __spec__.jsonc file (#23476)
This makes writing these tests a little easier.
2024-04-20 22:47:10 +00:00
Divy Srivastava
c0f40ed81a
fix(ext/node): implement process.kill in Rust (#23130)
Closes https://github.com/denoland/deno/issues/23056
2024-04-20 18:55:07 +05:30
Divy Srivastava
04c6785fae
fix(ext/node): cp into non-existent parent directory (#23469)
Fixes https://github.com/denoland/deno/issues/20604
2024-04-20 11:41:27 +00:00
Divy Srivastava
e0554ac4a2
fix(ext/node): Support env option in worker_thread (#23462)
Fixes https://github.com/denoland/deno/issues/23455
2024-04-20 09:18:10 +05:30
Matt Mastracci
472a370640
feat(runtime): Allow embedders to perform additional access checks on file open (#23208)
Embedders may have special requirements around file opening, so we add a
new `check_open` permission check that is called as part of the file
open process.
2024-04-19 18:12:03 -06:00
Matt Mastracci
365e1f48f7
feat(ext/http): Add addr to HttpServer (#23442)
Adds an `addr` field to `HttpServer` to simplify the pattern
`Deno.serve({ onListen({ port } => listenPort = port })`. This becomes:
`const server = Deno.serve({}); port = server.addr.port`.

Changes:
- Refactors `serve` overloads to split TLS out (in preparation for
landing a place for the TLS SNI information)
- Adds an `addr` field to `HttpServer` that matches the `addr` field of
the corresponding `Deno.Listener`s.
2024-04-19 18:09:50 -06:00
Asher Gomez
05b49a803f
FUTURE: remove Deno.customInspect (#23453) 2024-04-19 20:50:18 +10:00
David Sherret
c497e766f1
refactor: move redirect handling into deno_graph (#23444) 2024-04-19 01:43:28 +00:00
Bartek Iwańczuk
9e4ba982df
test: fix node_compat_test (#23446)
It's not clear to me how these tests worked correctly on CI,
 but they were failing hard locally because of two problems:
- missing env var that tests URL for fake npm registry
- trying to run a directory that contains native Node.js tests that
require a special harness
2024-04-19 01:42:18 +02:00
Bartek Iwańczuk
7b02f2aba6
test: deflake tests for rejection handled (#23448)
Fixes flakiness for rejection handled tests on Windows (7 failures in
the past day).
2024-04-18 23:40:15 +00:00
nokazn
3d841acf48
fix(cli): avoid deno add and deno vendor errors when deno.json is empty (#23439) 2024-04-18 15:48:15 -04:00