0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-18 19:33:00 -05:00
Commit graph

13077 commits

Author SHA1 Message Date
Divy Srivastava
8d3a95170c
fix(ext/node): set process.env as own property (#27891)
Fixes `gcp-metadata@6.1.1`

```
% deno eval "import 'npm:gcp-metadata@6.1.1'" # main
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')
    at Object.log (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:52:20)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:409:4)
    at Module._compile (node:module:745:34)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:755:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)

% target/debug/deno eval "import 'npm:gcp-metadata@6.1.1'" # this PR
```

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2025-02-12 10:01:19 +01:00
denobot
46e2f9a47e
2.1.9 (#27886)
Bumped versions for 2.1.9

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-31 01:21:43 +01:00
Nathan Whitaker
0f117bbd68
perf(crypto): use ring for asm implementations of sha256/sha512 (#27885)
Currently we are using the pure rust backend of `sha2`, which has subpar
performance compared to asm implementations. We already depend on
`ring`, so just use that instead of `sha2` for sha256/sha512 digests.

This also speeds up things like S3 uploads, which calculate sha digests
of the uploaded objects. On my local machine, this speeds up uploading a
100MB file (to a localhost s3 provider via`@aws-sdk/client-s3`) by about
2x

<details>

<summary>Benchmark:</summary>

```ts
import { createHmac } from "node:crypto";

for (
  const size of [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000]
) {
  const input = "a".repeat(size);
  Deno.bench({
    name: `sha256-${size}`,
    fn() {
      const _hash = createHmac("sha256", input).update(input).digest();
    },
  });
  Deno.bench({
    name: `sha512-${size}`,
    fn() {
      const _hash = createHmac("sha512", input).update(input).digest();
    },
  });
}
```

</details>

<details>

<summary>Results (arm64 macOS):</summary>

```
--- sha256-1 ---
../../deno/target/release/deno         2.527 µs    1.240 times faster
/Users/nathanwhit/.deno/bin/deno       3.132 µs    
--- sha512-1 ---
../../deno/target/release/deno         3.364 µs    1.071 times faster
/Users/nathanwhit/.deno/bin/deno       3.603 µs    
--- sha256-10 ---
../../deno/target/release/deno         3.060 µs    1.027 times faster
/Users/nathanwhit/.deno/bin/deno       3.144 µs    
--- sha512-10 ---
../../deno/target/release/deno         3.583 µs    1.047 times faster
/Users/nathanwhit/.deno/bin/deno       3.751 µs    
--- sha256-100 ---
../../deno/target/release/deno         3.695 µs    1.244 times faster
/Users/nathanwhit/.deno/bin/deno       4.598 µs    
--- sha512-100 ---
../../deno/target/release/deno         3.386 µs    1.188 times faster
/Users/nathanwhit/.deno/bin/deno       4.021 µs    
--- sha256-1000 ---
../../deno/target/release/deno         4.007 µs    3.230 times faster
/Users/nathanwhit/.deno/bin/deno      12.944 µs    
--- sha512-1000 ---
../../deno/target/release/deno         6.463 µs    1.466 times faster
/Users/nathanwhit/.deno/bin/deno       9.477 µs    
--- sha256-10000 ---
../../deno/target/release/deno        11.674 µs    6.981 times faster
/Users/nathanwhit/.deno/bin/deno      81.493 µs    
--- sha512-10000 ---
../../deno/target/release/deno        31.250 µs    1.740 times faster
/Users/nathanwhit/.deno/bin/deno      54.364 µs    
--- sha256-100000 ---
../../deno/target/release/deno        82.800 µs    9.393 times faster
/Users/nathanwhit/.deno/bin/deno     777.719 µs    
--- sha512-100000 ---
../../deno/target/release/deno       269.726 µs    1.851 times faster
/Users/nathanwhit/.deno/bin/deno     499.243 µs    
--- sha256-1000000 ---
../../deno/target/release/deno       808.662 µs    9.427 times faster
/Users/nathanwhit/.deno/bin/deno       7.623 ms    
--- sha512-1000000 ---
../../deno/target/release/deno         2.672 ms    1.795 times faster
/Users/nathanwhit/.deno/bin/deno       4.795 ms    
--- sha256-10000000 ---
../../deno/target/release/deno         7.823 ms    9.868 times faster
/Users/nathanwhit/.deno/bin/deno      77.201 ms    
--- sha512-10000000 ---
../../deno/target/release/deno        26.197 ms    1.846 times faster
/Users/nathanwhit/.deno/bin/deno      48.356 ms    
```

</details>

<details>

<summary>Results (x86_64 linux):</summary>

```
--- sha256-1 ---
/home/nathanwhit/.deno/bin/deno             10.726 µs    1.229 times faster
../../../deno/target/release-lite/deno      13.184 µs    
--- sha512-1 ---
/home/nathanwhit/.deno/bin/deno             13.177 µs    1.051 times faster
../../../deno/target/release-lite/deno      13.845 µs    
--- sha256-10 ---
/home/nathanwhit/.deno/bin/deno             13.156 µs    1.047 times faster
../../../deno/target/release-lite/deno      13.780 µs    
--- sha512-10 ---
/home/nathanwhit/.deno/bin/deno             14.386 µs    1.029 times faster
../../../deno/target/release-lite/deno      14.807 µs    
--- sha256-100 ---
/home/nathanwhit/.deno/bin/deno             14.580 µs    1.083 times faster
../../../deno/target/release-lite/deno      15.789 µs    
--- sha512-100 ---
/home/nathanwhit/.deno/bin/deno             13.477 µs    1.131 times faster
../../../deno/target/release-lite/deno      15.238 µs    
--- sha256-1000 ---
../../../deno/target/release-lite/deno      17.208 µs    1.116 times faster
/home/nathanwhit/.deno/bin/deno             19.198 µs    
--- sha512-1000 ---
../../../deno/target/release-lite/deno      21.168 µs    1.026 times faster
/home/nathanwhit/.deno/bin/deno             21.717 µs    
--- sha256-10000 ---
../../../deno/target/release-lite/deno      33.586 µs    1.990 times faster
/home/nathanwhit/.deno/bin/deno             66.837 µs    
--- sha512-10000 ---
../../../deno/target/release-lite/deno      53.338 µs    1.009 times faster
/home/nathanwhit/.deno/bin/deno             53.817 µs    
--- sha256-100000 ---
../../../deno/target/release-lite/deno     168.238 µs    3.063 times faster
/home/nathanwhit/.deno/bin/deno            515.354 µs    
--- sha512-100000 ---
../../../deno/target/release-lite/deno     383.311 µs    1.036 times faster
/home/nathanwhit/.deno/bin/deno            397.122 µs    
--- sha256-1000000 ---
../../../deno/target/release-lite/deno       1.474 ms    3.471 times faster
/home/nathanwhit/.deno/bin/deno              5.115 ms    
--- sha512-1000000 ---
../../../deno/target/release-lite/deno       3.658 ms    1.057 times faster
/home/nathanwhit/.deno/bin/deno              3.865 ms    
--- sha256-10000000 ---
../../../deno/target/release-lite/deno      16.438 ms    3.136 times faster
/home/nathanwhit/.deno/bin/deno             51.556 ms    
--- sha512-10000000 ---
../../../deno/target/release-lite/deno      37.128 ms    1.056 times faster
/home/nathanwhit/.deno/bin/deno             39.220 ms    
```

</details>
2025-01-31 00:39:11 +01:00
snek
b4b02576d0
fix(ext/node): add http information support (#27381)
Implements some client and server events to improve compat.
This change makes AWS SDKs more reliable and faster in Deno.

Fixes: https://github.com/denoland/deno/issues/27239
2025-01-30 23:28:55 +01:00
denobot
318646f767
2.1.8 (#27878)
Bumped versions for 2.1.8

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 19:19:27 +01:00
Divy Srivastava
7b8dc972b9
fix(core): Fix create_stack_trace from empty trace (#27873)
Fixes https://github.com/denoland/deno/issues/27849
2025-01-30 15:34:59 +01:00
Nathan Whitaker
c31b670323
fix(lsp): ignore errors on ambient module imports (#27855)
This makes it so imports of ambient modules (e.g. `$app/environment` in
svelte, any virtual module in vite, or other module provided by a
bundler) don't error in the LSP.

The way this works is that when we request diagnostics from TSC, we also
respond with the list of ambient modules. Then, in the diagnostics code,
we save diagnostics (produced by deno) that may be invalidated as an
ambient module and wait to publish the diagnostics until we've received
the ambient modules from TSC.

The actual ambient modules you get from TSC can contain globs, e.g.
`*.css`. So when we get new ambient modules, we compile them all into a
regex and check erroring imports against that regex. Ambient modules
should change rarely, so in most cases we should be using a pre-compiled
regex, which executes in linear time (wrt the specifier length).

TODO:
- Ideally we should only publish once, right now we publish with the
filtered specifiers and then the TSC ones
- deno check (#27633)
2025-01-30 15:34:59 +01:00
David Sherret
ea837b678e
fix(init): correct dev task for --lib (#27860) 2025-01-30 15:34:59 +01:00
Divy Srivastava
ee4ae8bd6b
fix(ext/node): implement crypto.hash (#27858)
Implement
[`crypto.hash`](https://nodejs.org/api/crypto.html#cryptohashalgorithm-data-outputencoding)
- one-shot version of `createHash`

Fixes #24945
2025-01-30 15:34:58 +01:00
David Sherret
157feb9b7d
fix(check): better handling of TypeScript in npm packages for type checking (#27853)
1. Allows resolving to `.ts` files for type checking.
2. Probes for `.ts` files to use for type checking.

To emphasize, this is only for type checking.
2025-01-30 15:34:58 +01:00
Phil Hawksworth
e710340080
docs: jsdocs for URL web API (#27850)
Adds references and examples to the documentation of the URL properties
which surface here:

https://docs.deno.com/api/web/~/URL

  `./tools/lint.js`
  `./tools/format.js`

---------

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2025-01-30 15:34:58 +01:00
David Sherret
7dd8e40f60
fix(check): compiler options from workspace members (#27785)
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2025-01-30 15:34:58 +01:00
David Sherret
97e1f4b374
chore: fix two locally failing on windows tests (#27845) 2025-01-30 15:34:58 +01:00
David Sherret
5212dc37c5
fix(process/windows): correct command resolution when PATH env var not uppercase (#27846)
Closes #27768
2025-01-30 15:34:58 +01:00
jia wei
3097d99d76
fix(npmrc): merge .npmrc in user's homedir and project (#27119) 2025-01-30 15:34:57 +01:00
Divy Srivastava
d58c70fbd1
fix(ext/node): clear tz cache when setting process.env.TZ (#27826) 2025-01-30 15:34:57 +01:00
Divy Srivastava
fc14bd93ff
fix(ext/crypto): fix jwk key_ops validation (#27827) 2025-01-30 15:34:57 +01:00
Nathan Whitaker
b8e2a73ce7
fix(ext/node): implement aes-128-ctr, aes-192-ctr, and aes-256-ctr (#27630)
Fixes https://github.com/denoland/deno/issues/24864

Need to add some tests, also unsure about the right counter size (went
with 128 bit to be safe)

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2025-01-30 15:34:57 +01:00
Yoshiya Hinosawa
41406d6cfd
fix(ext/node): do not apply socket-init-workaround to ipc socket (#27779)
This PR resolves 2 issues of Socket class of node compat (both are
related to playwright)

Currently `browser.launch()` of playwright is not working.
`browser.launch` opens PipeTransport (which is based on Pipe/IPC socket)
with the browser process. But that pipe doesn't start reading the data
because of the workaround #27662 (which pauses the socket at the
beginning if it's from playwright-core). This PR fixes this issue by
checking whether the given handle is `ipc` handle or not.

Another issue is that sock-init-workaround for TLS connection stopped
working at #27707 because of the changes of TLS socket initialization
steps. This change fixes the issue by correctly returning the function
in workaround path.

The added case `specs::npm::playwright_compat` checks both fixes with
actual playwright and playwright-core packages.

`browser.launch` issues
closes #16899
closes #27623 

`https.request` issue
closes #27658
2025-01-30 15:34:57 +01:00
Yoshiya Hinosawa
86a79f499d
chore: remove unused npm package fixtures (#27835) 2025-01-30 15:34:57 +01:00
David Sherret
55b19e3e7a
perf(node_resolver): reduce url to/from path conversions (#27839)
Extracted out of https://github.com/denoland/deno/pull/27838/files

Reduces some allocations by accepting either a pathbuf or url for the
referrer for resolution and returning either a pathbuf or url at the
end, which the caller can then convert into to their preferred state.

This is about 4% faster when still converting the final result to a url
and 6% faster when keeping the result as a path in a benchmark I ran.
2025-01-30 15:34:56 +01:00
David Sherret
690da479dd
fix(install/global): warn about not including auto-discovered config file (#27745)
Closes #17855
2025-01-30 15:34:56 +01:00
Divy Srivastava
14081fb953
fix(ext/crypto): export private x25519 JWK key (#27828)
Ref https://github.com/denoland/deno/issues/26431
2025-01-30 15:34:56 +01:00
David Sherret
0007b73552
chore: fix deno_resolver non-sync build (#27824) 2025-01-30 15:34:56 +01:00
Divy Srivastava
6fe2341897
fix(ext/node): implement X509Certificate#checkHost (#27821)
Fixes https://github.com/denoland/deno/issues/27619
2025-01-30 15:34:56 +01:00
Divy Srivastava
2b27d342d8
fix(ext/node): fix panic when invalid AES GCM key size (#27818)
Fixes https://github.com/denoland/deno/issues/27807
2025-01-30 15:34:56 +01:00
Divy Srivastava
2f13542b69
fix(ext/node): fix async variant of brotliDecompress (#27815)
Fixes https://github.com/denoland/deno/issues/27729
2025-01-30 15:34:55 +01:00
Divy Srivastava
331f2c77c2
chore(ext/node): remove internal/streams/buffer_list.mjs (#27822)
This was never used internally and not supposed to be public either.
2025-01-30 15:34:55 +01:00
Divy Srivastava
b3c7ee4504
fix(ext/node): scrypt panic when log_n > 64 (#27816)
Throws an error instead of panic. Ref
https://github.com/denoland/deno/issues/27716
2025-01-30 15:34:55 +01:00
Divy Srivastava
a2d0368444
fix(core): handle dyn imports exceeding call stack size (#27825)
Fixes https://github.com/denoland/deno/issues/27736
2025-01-30 15:34:55 +01:00
Yoshiya Hinosawa
1baa33f1ee
fix(ext/node): npm:mqtt compatibility (#27792) 2025-01-30 15:34:55 +01:00
Cre3per
d96d1c6c0d
fix(ext/fetch): update h2 to fix sending a PROTOCOL_ERROR instead of REFUSED_STREAM when receiving oversized headers (#27531)
Fixes #26490

Related PR in h2 https://github.com/hyperium/h2/pull/792  
Related release of h2 https://github.com/hyperium/h2/releases/tag/v0.4.6
2025-01-30 15:34:55 +01:00
Bartek Iwańczuk
244bf5c2be
perf(lsp): cache completion item resolution during request (#27831)
This commit adds a simple HashMap cache to completion requests.

On a test project the time to compute completions went from 1200ms
to 75ms and the cache contained ~300 entries when 8000 completion
items were produced by the TSC.

This is a short-lived cache and is discarded once the completion
request is finished. In a follow up commits we could make it persist
between requests.
2025-01-30 15:34:55 +01:00
Kenta Moriuchi
77f6bd0db3
chore: remove LSP global symbols count tests (#27806)
Closes #23102
2025-01-30 15:34:54 +01:00
David Sherret
20a910e5f8
fix(node): align type stripping in node_modules error message with Node (#27809) 2025-01-30 15:34:54 +01:00
Kenta Moriuchi
84429352da
fix(types): Deno.readDirSync's type returns an IteratorObject (#27805) 2025-01-30 15:34:54 +01:00
David Sherret
d7b1f99d7a
refactor: make PackageJsonCache injectable (#27800)
This used to be complicated to do, but is now trivial.
2025-01-30 15:34:54 +01:00
Yoshiya Hinosawa
134f5e1282
chore: update ensure_registry_files_local to handle scoped packages (#27801) 2025-01-30 15:34:54 +01:00
Bartek Iwańczuk
0273f30974
refactor(tsc): remove TS program creation during snapshotting (#27797)
This commit refactors how a snapshot is created for the TypeScript
compiler.

Instead of having 4 ops, only a single op ("op_load") is left. This is
achieved by not creating a "ts.Program" during snapshotting, that during
benchmarking doesn't provide much benefit.

This greatly simplifies build script for the TS snapshot and opens up
way to simplify it even further in follow up PRs.
2025-01-30 15:34:54 +01:00
Yoshiya Hinosawa
d06e41ea9d
chore: trim registry.json files in tests/registry/npm (#27798) 2025-01-30 15:34:53 +01:00
David Sherret
5333339deb
refactor(node_resolver): remove some allocations and lookups (#27799) 2025-01-30 15:34:53 +01:00
David Sherret
a63f614ba1
refactor: add WorkspaceFactory and ResolverFactory (#27766)
Allows easily constructing a `DenoResolver` using the exact same logic
that we use in the CLI (useful for dnt and for external bundlers). This
code is then used in the CLI to ensure the logic is always up-to-date.

```rs
use std::rc::Rc;

use deno_resolver:🏭:ResolverFactory;
use deno_resolver:🏭:WorkspaceFactory;
use sys_traits::impls::RealSys;

let sys = RealSys;
let cwd = sys.env_current_dir()?;
let workspace_factory = Rc::new(WorkspaceFactory::new(sys, cwd, Default::default()));
let resolver_factory = ResolverFactory::new(workspace_factory.clone(), Default::default());
let deno_resolver = resolver_factory.deno_resolver().await?;
```
2025-01-30 15:34:53 +01:00
David Sherret
f81debe9f6
fix: do not log cache creation failure on readonly file system (#27794) 2025-01-30 15:34:53 +01:00
Luca Casonato
e01719ba60
fix(publish): unfurl sloppy imports in d.ts files and type imports (#27793)
Fixes a bug discovered while trying to publish a package with .js +
.d.ts with sloppy imports.
2025-01-30 15:34:53 +01:00
Bartek Iwańczuk
212b6e7a21
refactor(tsc): split TS compiler into multiple files, use ESM (#27784)
This is a pure refactor, the `99_main_compiler.js` file
was getting out of hand, being over 1500 lines and serving
3 distinct purposes:
- snapshotting
- type-checking
- running LSP

The file was split into:
- 97_ts_host.js
- 98_lsp.js
- 99_main_compiler.js
2025-01-30 15:34:53 +01:00
David Sherret
d29d4ca648
refactor: use DataUrl from deno_media_type (#27783)
This was moved from deno_graph to deno_media_type.
2025-01-30 15:34:52 +01:00
David Sherret
26ced754fd
chore: fix hmr build (#27781)
Closes #27761
2025-01-30 15:34:52 +01:00
Nayeem Rahman
984a775f89
fix(lsp): silence debug error for 'move to a new file' action (#27780) 2025-01-30 15:34:52 +01:00
Divy Srivastava
7ec06b541e
fix(ext/node): reference error in zlib.crc32 (#27777)
Fixes https://github.com/denoland/deno/issues/27774
2025-01-30 15:34:52 +01:00
snek
9ddb8315a5
feat(unstable): support https otlp endpoints (#27743)
Support HTTPS protocol for otel exporting. Includes support for
`OTEL_EXPORTER_OTLP_CERTIFICATE`, `OTEL_EXPORTER_OTLP_CLIENT_KEY`, and
`OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE`

Fixes: https://github.com/denoland/deno/issues/27703
2025-01-30 15:34:52 +01:00