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

4844 commits

Author SHA1 Message Date
David Sherret
7b0a7b1976
chore: upgrade to Rust 1.70.0 (#19345)
Co-authored-by: linbingquan <695601626@qq.com>
2023-06-09 01:13:23 +02:00
David Sherret
ddba4e8c4d
fix: upgrade to deno_ast 0.27 (#19375)
Closes #19148
2023-06-09 01:13:23 +02:00
Kenta Moriuchi
fb6b518d4d
chore: update deno_lint to 0.46.0 (#19372) 2023-06-09 01:13:22 +02:00
nasa
4f7b109b93
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-09 01:13:22 +02:00
Leo Kettmeir
26506ff0c2
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-09 01:13:22 +02:00
Mathias Lafeldt
cd041fd128
feat(runtime): support creating workers using custom v8 params (#19339)
In order to limit the memory usage of isolates via heap_limits.
2023-06-09 01:13:22 +02:00
Koen
2d60600724
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-09 01:13:21 +02:00
Nayeem Rahman
d05981a611
refactor(core): remove force_op_registration and cleanup JsRuntimeForSnapshot (#19353)
Addresses
https://github.com/denoland/deno/pull/19308#discussion_r1212248194. 

Removes force_op_registration as it is no longer necessary.
2023-06-09 01:13:21 +02:00
Marvin Hagemeister
08813ea25e
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-09 01:13:20 +02:00
nasa
6f02bfd181
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-09 01:13:20 +02:00
Hirotaka Tagawa / wafuwafu13
b995c13f03
chore(node_compat): fix path strings generated by setup.ts (#19347) 2023-06-09 01:13:20 +02:00
Bartek Iwańczuk
544f48c23c
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-09 01:13:20 +02:00
Nayeem Rahman
6836e5a6eb
refactor(core): don't pass op state to prepare_module_load() (#19332)
It's not used anymore. Subsequently allows removing
`ModuleMap::op_state`, allowing `ModuleMap` to have a sane default so
`JsRuntime::module_map` no longer needs to be optional.
2023-06-09 01:13:19 +02:00
Matt Mastracci
8f9a05f16e
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-06-09 01:13:19 +02:00
Marvin Hagemeister
34ab009e3c
fix(runtime): add missing SIGIOT alias to SIGABRT (#19333) 2023-06-09 01:13:19 +02:00
Leo Kettmeir
a6b0866fb6
refactor: further work on node http client (#19327)
Closes https://github.com/denoland/deno/issues/18300
2023-06-09 01:13:18 +02:00
Matt Mastracci
782db80629
chore(core): Split JsRuntimeForSnapshot from JsRuntime (#19308)
This cleans up `JsRuntime` a bit more:

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

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-09 01:13:18 +02:00
Marvin Hagemeister
f89b2c5ca6
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-06-09 01:13:18 +02:00
David Sherret
f63b13fc96
fix: do not show cache initialization errors if stderr is piped (#18920)
Closes #18918
2023-06-09 01:13:17 +02:00
David Sherret
03398ddace
feat(runtime): add WorkerLogLevel (#19316)
This is not really used yet, but provides some infrastructure for doing
more fine grained logging in JS. I will add warn messages in a future
PR.
2023-06-09 01:13:17 +02:00
denobot
ea6cd3f1fc
1.34.1 (#19310)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-30 01:30:46 +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
92080ff6f6
chore: maybe fix cli/standalone/virtual_fs tests on main (#19295)
Not sure why these don't fail on a PR run:
https://github.com/denoland/deno/actions/runs/5102317156/jobs/9171796164

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

Probably fixes #19251 (I'm still unable to reproduce).
2023-05-27 10:33:15 -04:00
Leo Kettmeir
be59e93220
refactor(node/http): don't use readablestream for writing to request (#19282)
Refactors the internal usage of a readablestream to write to the
resource directly

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-27 15:42:20 +02:00
David Sherret
d0c5ff42f4
fix(compile): implicit read permission to npm vfs (#19281)
Closes #19280
2023-05-26 13:33:38 -04:00
Bartek Iwańczuk
d72e0281ff
chore: upgrade rusty_v8 to 0.73.0 (#19278) 2023-05-26 16:17:12 +02:00
Bartek Iwańczuk
160fe9787e
fix(node): make 'v8.setFlagsFromString' a noop (#19271)
Towards https://github.com/denoland/deno/issues/16460
2023-05-26 15:41:03 +02:00
Bartek Iwańczuk
d5a8a3d69f
chore: remove useless benchmark (#19272)
This benchmark is useless and only gives several hundred thousand
messages of failure.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-05-26 13:26:21 +00:00
David Sherret
25cbd97ab7
chore(lsp/tests): diagnostic synchronization (reland) (#19270)
Merge on approval as it fixes the flaky test.
2023-05-26 08:10:18 +02:00
Bartek Iwańczuk
e95f098ae3
fix(napi): properly handle arguments in napi_get_cb_info (#19269)
Closes https://github.com/denoland/deno/issues/17213
2023-05-26 05:02:12 +00:00
Bartek Iwańczuk
512d5337c4
fix(napi): clear currently registering module slot (#19249)
This commit fixes problem with loading N-API modules that use 
the "old" way of registration (using "napi_module_register" API).
The slot was not cleared after loading modules, causing subsequent
calls that use the new way of registration (using 
"napi_register_module_v1" API) to try and load the previous module.

Ref https://github.com/denoland/deno/issues/16460

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-05-26 10:10:17 +05:30
Bartek Iwańczuk
7ae55e75d8
Revert "chore(lsp/tests): diagnostic synchronization (#19264)" (#19268)
This reverts commit 89026abe39.

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

For #19251
2023-05-25 15:29:58 -04:00
David Sherret
2ebd61ee1b
fix(compile): handle when DENO_DIR is readonly (#19257)
Closes #19253
2023-05-25 14:27:45 -04:00
Luca Casonato
76400149a4
fix: don't print release notes on version check prompt (#19252) 2023-05-25 14:45:11 +02:00
denobot
935071dd0e
1.34.0 (#19246)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24 23:38:01 +00:00
David Sherret
91ca9904b5
refactor: upgrade to deno_npm 0.6 (#19244) 2023-05-24 16:23:10 -04:00
Hirotaka Tagawa / wafuwafu13
114ec3c1f7
feat(ext/fs): add isBlockDevice, isCharDevice, isFifo, isSocket to FileInfo (#19008)
`isFile`, `isDirectory`, `isSymlink` are defined in `Deno.FileInfo`, but
`isBlockDevice`, `isCharacterDevice`, `isFIFO`, `isSocket` are not
defined.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24 21:18:13 +02:00
David Sherret
ba6f573b4e
fix(npm): create node_modules/.deno/node_modules folder (#19242)
This is what pnpm does and we were missing it. It makes modules work
which have a dependency on something, but don't say they have that
dependency, but that dep is still in the tree somewhere.
2023-05-24 15:04:21 -04:00
Matt Mastracci
0fbfdaf901
chore(core): Ensure that net test ports aren't used elsewhere (#19243)
Fixes occasional test flake due to overlapping ports
2023-05-24 12:36:41 -06:00
Levente Kurusa
1174715f99
feat(ext/http): Brotli Compression (#19216)
Add Brotli streaming compression to HTTP
2023-05-24 19:54:47 +02:00
Bartek Iwańczuk
e56695daa8
fix(napi): add napi_async_init and napi_async_destroy (#19234)
We don't have support for "AsyncContext" in "node:async_hooks" 
module, so these two APIs are just noops.

Towards https://github.com/denoland/deno/issues/18610.
2023-05-24 15:41:43 +02:00
Bartek Iwańczuk
0bb5bbc7a0
fix(node): fire 'unhandledrejection' event when using node: or npm: imports (#19235)
This commit fixes emitting "unhandledrejection" event when there are
"node:" or "npm:" imports. 

Before this commit the Node "unhandledRejection" event was emitted
using a regular listener for Web "unhandledrejection" event. This
listener was installed before any user listener had a chance to be 
installed which effectively prevent emitting "unhandledrejection" 
events to user code.

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

Ideally, we would only ever use a node_modules directory with this
explicit opt-in so everything is very clear, but we still have this
automatic scenario when there's a package.json in order to make more
node projects work out of the box.
2023-05-23 18:51:48 -04:00