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

9016 commits

Author SHA1 Message Date
David Sherret
12f3c1a359 fix: upgrade to TypeScript 5.0.3 (#18532) 2023-03-31 11:43:20 -06:00
David Sherret
cd7071beb2 fix(lsp): better handling of data: urls (#18527)
1. Log instead of error when the referrer can't be found
2. Fixes typescript to resolve data urls correctly. Properly documented
here:
https://github.com/denoland/TypeScript/pull/4/files#diff-180da7c288743d11d8590d30f0c07c48e5dcf291aa671bbea0dd520a9a1359d2

Closes #18524
2023-03-31 11:43:20 -06:00
Divy Srivastava
8088a7b786 perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525)
This commit adds a new core API `opAsync2` to call an async op with
atmost 2 arguments. Spread argument iterators has a pretty big perf hit
when calling ops.

| name | avg msg/sec/core |
| --- | --- |
| 1.32.1 | `127820.750000` |
| #18506 | `140079.000000` |
| #18506 + #18509 | `150104.250000` |
| #18506 + #18509 + this | `157340.000000` |
2023-03-31 11:43:20 -06:00
Divy Srivastava
a23252d975 fix(ops): fallback when FastApiOneByteString is not utf8 (#18518)
Fixes https://github.com/denoland/deno/issues/18255
2023-03-31 11:43:20 -06:00
Divy Srivastava
3b65d297c7 perf: const op declaration (#18288)
Co-authored-by: Levente Kurusa <lkurusa@kernelstuff.org>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-31 11:43:20 -06:00
Divy Srivastava
0cd0a9d5ed perf(ext/websocket): efficient event kind serialization (#18509)
Use u16 to represent the kind of event (0 - 6) & event code > 6 is
treated as the close code. This way we can represent all events + the
close code in a single JS number. This is safe because (as per RFC 6455)
close code from 0-999 are reserved & not used.

| name | avg msg/sec/core |
| --- | --- |
| deno_main | `127820.750000` |
| deno #18506 | `140079.000000` |
| deno #18506 + this | `150104.250000` |
2023-03-31 11:43:20 -06:00
David Sherret
5d20c36eaf fix(lsp): include all diagnosable documents on initialize (#17979)
Closes https://github.com/denoland/vscode_deno/issues/797
Closes https://github.com/denoland/deno/issues/11190
Closes https://github.com/denoland/vscode_deno/issues/811
Closes https://github.com/denoland/vscode_deno/issues/761
Closes https://github.com/denoland/vscode_deno/issues/585
Closes https://github.com/denoland/vscode_deno/issues/561
Closes https://github.com/denoland/vscode_deno/issues/410
2023-03-31 11:43:20 -06:00
Luca Casonato
5949321c55 fix(dts): improve types for the Deno.KV API (#18510) 2023-03-31 11:43:20 -06:00
Luca Casonato
e81f677fe4 feat(ext/kv): return versionstamp from set/commit (#18512)
This commit updates the `Deno.Kv` API to return the new commited
versionstamp for the mutated data from `db.set` and `ao.commit`. This is
returned in the form of a `Deno.KvCommitResult` object that has a
`versionstamp` property.
2023-03-31 11:43:20 -06:00
Geert-Jan Zwiers
7f88b9e442 fix(coverage): ignore files from npm registry (#18457)
Fixes https://github.com/denoland/deno/issues/17664 and part of
https://github.com/denoland/deno/issues/18454 by excluding files
belonging to npm modules by default in the coverage output.
2023-03-31 11:43:20 -06:00
Divy Srivastava
842e359f25 perf(ext/websocket): special op for sending binary data frames (#18506)
Easy perf win by avoiding deserializing `SendValue` through serde_v8. 

| name | avg msg/sec/core |
| --- | --- |
| deno_main | `127820.750000` |
| deno_this | `140079.000000` |
2023-03-31 11:43:20 -06:00
David Sherret
2153d443c8 fix(lsp): textDocument/references should respect includeDeclaration (#18496) 2023-03-31 11:43:20 -06:00
Divy Srivastava
8daf893e11 perf(ext/websocket): special op for sending text data frames (#18507)
Similar to #18506 but for Text frames.
2023-03-31 11:43:20 -06:00
David Sherret
04de3496cc docs: clarify Deno.consoleSize returns the window size (#18508)
Closes #18477
2023-03-31 11:43:20 -06:00
Bartek Iwańczuk
5ea494578a Revert "refactor(ext/node): Use Deno.inspect (#17960)" (#18491)
This reverts commit a3529d0232.

This change made debugging Node tests very hard - `AssertionError` is
now printed as `[Circular *1]` giving no visibility what failed.

We need to align two implementations together and remove this one then.
2023-03-31 11:43:20 -06:00
David Sherret
9bc81b8ac7 fix(repl): improve package.json support (#18497)
1. Fixes a cosmetic issue in the repl where it would display lsp warning
messages.
2. Lazily loads dependencies from the package.json on use.
3. Supports using bare specifiers from package.json in the REPL.

Closes #17929
Closes #18494
2023-03-31 11:43:20 -06:00
Yoshiya Hinosawa
6d03a55934 chore(ext/node): run node compat parallel tests in core number concurrency (#18505)
We currently run the all test cases in `parallel` category at the same
time, which invokes hundreds process at the same time, and that seems
causing some flakiness in CI. (maybe related to #18487)

This PR limits the concurrency to the number of cpu cores. This is more
aligned to how Node.js run their `parallel` test in their repository.
42c4a35952/Makefile (L356)
2023-03-31 11:43:20 -06:00
Bartek Iwańczuk
c385678d66 test: fix test_check_origin_not_supported (#18504)
Merge of dotland and dotcom caused this test to fail.
2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
8497cef156 refactor(ext/node): add NodeEnv::Fs associated type (#18484)
This commit adds associated type to "NodeEnv" trait, called "Fs".

The "Fs" type has a trait bound on "NodeFs", which specifies APIs
required for all ops and resolution APIs to function.

A "RealFs" implementation of "NodeFs" is exported from the "deno_node"
crate, that provides a default implementation for the trait.

All code in "deno_node" extension was changed to use the "NodeFs" trait
to handle file system operations, instead of relying on APIs from the
standard library.
2023-03-31 11:43:19 -06:00
David Sherret
e7b80efca1 refactor(lsp): remove boolean parameters on documents.documents(...) (#18493)
I think this makes things clearer at the call sites.
2023-03-31 11:43:19 -06:00
Andrew Nester
b5024c6998 test(ext/node): add timers_tests.ts from std/node (#18472) 2023-03-31 11:43:19 -06:00
Andrew Nester
c31ddbde4b test(ext/node): add string_decoder_test.ts from std/node (#18473) 2023-03-31 11:43:19 -06:00
David Sherret
dba4b6ca80 chore: fix flaky pty_internal_repl (#18486) 2023-03-31 11:43:19 -06:00
Christian Dürr
269af39082 fix: Add missing processenv winapi feature to deno_io (#18485)
Currently the `processenv` feature is not explicitly requested by
`deno_io`, however it is using the `processenv` module. This will
prevent downstream users from building on Windows.

I'd assume that this doesn't popup in Deno itself since another crate is
enabling this feature.
2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
e9aa09bfd4 test(lsp): make lsp_completions_auto_import more robust (#18482)
A completely unrelated change in
https://github.com/denoland/deno/pull/18286 threw of this test.

These changes make it more robust and easier to update in such cases.
2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
bd80ebffc4 refactor(ext/node): change extension type parameter (#18483)
This commit changes the type parameter for "deno_node" extension, from
`P: NodePermission` to `Env: NodeEnv`.

`NodeEnv` is a new trait that has associated type `P: NodePermission`.

This is a stepping stone to support swappable file system for the
extension, that will be added as a second associated type to the 
`NodeEnv` trait.
2023-03-31 11:43:19 -06:00
David Sherret
f861bd2337 chore: restore pty tests and make them run on the Linux CI (#18424)
1. Rewrites the tests to be more back and forth rather than getting the
output all at once (which I believe was causing the hangs on linux and
maybe mac)
2. Runs the pty tests on the linux ci.
3. Fixes a bunch of tests that were just wrong.
4. Adds timeouts on the pty tests.
2023-03-31 11:43:19 -06:00
Matt Mastracci
598e9be54e fix(core): restore cache journal mode to TRUNCATE and tweak tokio test in CacheDB (#18469)
Fast-follow on #18401 -- the reason that some tests were panicking in
the `CacheDB` `impl Drop` was that the cache itself was being dropped
during panic and the runtime may or may not still exist at that point.
We can reduce the actual tokio runtime testing to where it's needed.

In addition, we return the journal mode to `TRUNCATE` to avoid the risk
of data corruption.
2023-03-31 11:43:19 -06:00
Ryan Dahl
dcf384259f refactor: move shared library tests to their own file (#18479) 2023-03-31 11:43:19 -06:00
Kamal Singh
0df7e6636a test(node/fs): add fs.Dir tests (#18463)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-03-31 11:43:19 -06:00
Yoshiya Hinosawa
b71b6665b3 fix(ext/node): implement crypto.Sign (RSA/PEM/SHA{224,256,384,512}) (#18471) 2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
4e190bb537 Reland "refactor: remove Deno[Deno.internal].nodeUnstable namespace" (#18475)
This reverts commit 357bcfcf79.
2023-03-31 11:43:19 -06:00
Divy Srivastava
e40f44f79f feat(ext/node): add crypto.checkPrime API (#18465)
Towards #18455 

This commit implements `checkPrimeSync` and `checkPrime` in node:crypto
using the Miller-Rabin primality test (fun fact: it actually is a test
for composite numbers)

It first compares the candidate against many known small primes and if
not, proceeds to run the Miller-Rabin primality test.
http://nickle.org/examples/miller-rabin.5c used as reference
implementation.
2023-03-31 11:43:19 -06:00
Divy Srivastava
2d3be63153 chore(ext/node): port pbkdf2 to Rust (#18470)
Towards #18455
2023-03-31 11:43:19 -06:00
Andrew Nester
22f5c2504e chore: add test for Linux shared libraries (#18461)
Closes #18266
2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
6c0df5e94e refactor(runtime): manual serialization of bootstrap data (#18448)
This commit changes how data required to bootstrap main and worker
runtime is serialized. 

Instead of relying on serde_v8 and using JSON object,
we're doing manual serialization to a "v8::Array". This limits number 
of V8 strings that need to be serialized by 16. 

It also made it clear that some data could be obtained during
snapshotting instead of during bootstrap.
2023-03-31 11:43:19 -06:00
Matt Mastracci
d23579fe6d feat(core): initialize SQLite off-main-thread (#18401)
This gets SQLite off the flamegraph and reduces initialization time by
somewhere between 0.2ms and 0.5ms. In addition, I took the opportunity
to move all the cache management code to a single place and reduce
duplication. While the PR has a net gain of lines, much of that is just
being a bit more deliberate with how we're recovering from errors.

The existing caches had various policies for dealing with cache
corruption, so I've unified them and tried to isolate the decisions we
make for recovery in a single place (see `open_connection` in
`CacheDB`). The policy I chose was:

 1. Retry twice to open on-disk caches
 2. If that fails, try to delete the file and recreate it on-disk
3. If we fail to delete the file or re-create a new cache, use a
fallback strategy that can be chosen per-cache: InMemory (temporary
cache for the process run), BlackHole (ignore writes, return empty
reads), or Error (fail on every operation).

The caches all use the same general code now, and share the cache
failure recovery policy.

In addition, it cleans up a TODO in the `NodeAnalysisCache`.
2023-03-31 11:43:19 -06:00
Marvin Hagemeister
f21d48bc0a fix(ext/node): add missing _preloadModules hook (#18447)
This internal node hook is used by libraries such as `ts-node` when used
as a require hook `node -r ts-node/register`. That combination is often
used with test frameworks like `mocha` or `jasmine`.

We had a reference to `Module._preloadModules` in our code, but the
implementation was missing. While fixing this I also noticed that the
`fakeParent` module that we create internally always threw because of
the `pathDirname` check on the module id in the constructor of `Mdoule`.
So this code path was probably broken for a while.

```txt
✖ ERROR: Error: Empty filepath.
    at pathDirname (ext:deno_node/01_require.js:245:11)
    at new Module (ext:deno_node/01_require.js:446:15)
    at Function.Module._resolveFilename (ext:deno_node/01_require.js:754:28)
    at Function.resolve (ext:deno_node/01_require.js:1015:19)
```
2023-03-31 11:43:19 -06:00
Bartek Iwańczuk
381a3c4369 refactor(cli): remove Lazy<String> and fix help outputs (#18462)
This `Lazy<String>` calls were showing up on flamegraph and there's
really no point in using them.
2023-03-31 11:43:19 -06:00
Divy Srivastava
c4ea1e3774 feat: port node:zlib to rust (#18291) 2023-03-31 11:43:19 -06:00
Divy Srivastava
7c6ef81267 fix(cli/bench): look for clone3 syscalls for thread count (#18456) 2023-03-31 11:43:18 -06:00
Bartek Iwańczuk
e3a104fdaa Revert "refactor: remove Deno[Deno.internal].nodeUnstable namespace (… (#18458)
…#18449)"

This reverts commit d1a9c4cd7c.

Appears this made CI very flaky on macOS, but I can't repeat it locally
yet
2023-03-31 11:43:18 -06:00
Kenta Moriuchi
5ef4cefa26 fix(streams): add support Float64Array to ReadableStreamByobReader (#18188) 2023-03-31 11:43:18 -06:00
Bartek Iwańczuk
8b7524bcef refactor: remove Deno[Deno.internal].nodeUnstable namespace (#18449)
Since we can preserve ops in the snapshot these days, we no longer
need to have "Deno[Deno.internal].nodeUnstable" namespace.

Instead, various built-in Node.js modules can use appropriate APIs
directly.
2023-03-31 11:43:18 -06:00
Marvin Hagemeister
e06bd19a69 fix(cli): add colors to "Module not found" error frame (#18437) 2023-03-31 11:43:18 -06:00
Max Dahlgren
2813a27364 test(ext/node): Port crypto tests from std/node (#18382) 2023-03-31 11:43:18 -06:00
Nayeem Rahman
9ee4e51ae4 fix(cli): don't store blob and data urls in the module cache (#18261) 2023-03-31 11:43:18 -06:00
Yoshiya Hinosawa
0389b7bbba chore: document Node.js compat test setup script (#18381) 2023-03-31 11:43:18 -06:00
Mike Mulchrone
02401b2891 chore: Improving FS Error Message for op_realpath_sync and op_realpath_async (#18404)
#17526
2023-03-31 11:43:18 -06:00
滑威
7fa2bf34eb fix(cli): deno upgrade file permission (#18427) 2023-03-31 11:43:18 -06:00