summaryrefslogtreecommitdiff
path: root/cli/worker.rs
AgeCommit message (Collapse)Author
2024-03-13perf(permissions): Fast exit from checks when permission is in ↵Matt Mastracci
"fully-granted" state (#22894) Skips the access check if the specific unary permission is in an all-granted state. Generally prevents an allocation or two. Hooks up a quiet "all" permission that is automatically inherited. This permission will be used in the future to indicate that the user wishes to accept all side-effects of the permissions they explicitly granted. The "all" permission is an "ambient flag"-style permission that states whether "allow-all" was passed on the command-line.
2024-03-13fix(ext/node): allow automatic worker_thread termination (#22647)Satya Rohith
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-03-11chore: enable clippy unused_async rule (#22834)David Sherret
2024-03-11fix(ext/node): make worker setup synchronous (#22815)Bartek Iwańczuk
This commit fixes race condition in "node:worker_threads" module were the first message did a setup of "threadId", "workerData" and "environmentData". Now this data is passed explicitly during workers creation and is set up before any user code is executed. Closes https://github.com/denoland/deno/issues/22783 Closes https://github.com/denoland/deno/issues/22672 --------- Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-03-05chore: upgrade deno_core (#22699)Bartek Iwańczuk
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-02-23fix(ext/node): set correct process.argv0 (#22555)Satya Rohith
2024-02-15chore: add DENO_FUTURE env var (#22318)Divy Srivastava
Closes https://github.com/denoland/deno/issues/22315 ``` ~> DENO_FUTURE=1 target/debug/deno > globalThis.window undefined ```
2024-02-13feat: denort binary for `deno compile` (#22205)Divy Srivastava
This introduces the `denort` binary - a slim version of deno without tooling. The binary is used as the default for `deno compile`. Improves `deno compile` final size by ~2.5x (141 MB -> 61 MB) on Linux x86_64.
2024-02-10chore: deno_core bump (#22379)Matt Mastracci
- Updates to V8 12.1.285.27 https://github.com/denoland/rusty_v8/pull/1383 - Swaps Box for Rc for `source_map_getter`
2024-02-07refactor: extract out `runtime::colors` to `deno_terminal::colors` (#22324)David Sherret
2024-01-26fix: make deprecation warnings less verbose (#22128)Bartek Iwańczuk
This commit makes deprecation warnings less verbose by default. Only a single warnings is issued per deprecated API use. `DENO_VERBOSE_WARNINGS` env var can be provided to enable more detailed logging for each use of API including a stack trace. https://github.com/denoland/deno/assets/13602871/9c036c84-0044-4cb6-9c8e-deb641f43712
2024-01-25chore(cli): split 40_testing (#22112)Matt Mastracci
No code changes -- just splitting 40_testing into three files and removing a couple of unused lines of code.
2024-01-18feat: Start warning on each use of a deprecated API (#21939)Bartek Iwańczuk
This commit introduces deprecation warnings for "Deno.*" APIs. This is gonna be quite noisy, but should tremendously help with user code updates to ensure smooth migration to Deno 2.0. The warning is printed at each unique call site to help quickly identify where code needs to be adjusted. There's some stack frame filtering going on to remove frames that are not useful to the user and would only cause confusion. The warning can be silenced using "--quiet" flag or "DENO_NO_DEPRECATION_WARNINGS" env var. "Deno.run()" API is now using this warning. Other deprecated APIs will start warning in follow up PRs. Example: ```js import { runEcho as runEcho2 } from "http://localhost:4545/run/warn_on_deprecated_api/mod.ts"; const p = Deno.run({ cmd: [ Deno.execPath(), "eval", "console.log('hello world')", ], }); await p.status(); p.close(); async function runEcho() { const p = Deno.run({ cmd: [ Deno.execPath(), "eval", "console.log('hello world')", ], }); await p.status(); p.close(); } await runEcho(); await runEcho(); for (let i = 0; i < 10; i++) { await runEcho(); } await runEcho2(); ``` ``` $ deno run --allow-read foo.js Warning ├ Use of deprecated "Deno.run()" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use "Deno.Command()" API instead. │ └ Stack trace: └─ at file:///Users/ib/dev/deno/foo.js:3:16 hello world Warning ├ Use of deprecated "Deno.run()" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use "Deno.Command()" API instead. │ └ Stack trace: ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18) └─ at file:///Users/ib/dev/deno/foo.js:13:7 hello world Warning ├ Use of deprecated "Deno.run()" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use "Deno.Command()" API instead. │ └ Stack trace: ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18) └─ at file:///Users/ib/dev/deno/foo.js:14:7 hello world Warning ├ Use of deprecated "Deno.run()" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use "Deno.Command()" API instead. │ └ Stack trace: ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18) └─ at file:///Users/ib/dev/deno/foo.js:17:9 hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world Warning ├ Use of deprecated "Deno.run()" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use "Deno.Command()" API instead. │ ├ Suggestion: It appears this API is used by a remote dependency. │ Try upgrading to the latest version of that dependency. │ └ Stack trace: ├─ at runEcho (http://localhost:4545/run/warn_on_deprecated_api/mod.ts:2:18) └─ at file:///Users/ib/dev/deno/foo.js:20:7 hello world ``` Closes #21839
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-19fix(node): child_process IPC on Windows (#21597)Divy Srivastava
This PR implements the child_process IPC pipe between parent and child. The implementation uses Windows named pipes created by parent and passes the inheritable file handle to the child. I've also replace parts of the initial implementation which passed the raw parent fd to JS with resource ids instead. This way no file handle is exposed to the JS land (both parent and child). `IpcJsonStreamResource` can stream upto 800MB/s of JSON data on Win 11 AMD Ryzen 7 16GB (without `memchr` vectorization)
2023-12-13refactor(cli): update to new deno_core promise/call methods (#21519)Matt Mastracci
2023-12-13fix: implement child_process IPC (#21490)Divy Srivastava
This PR implements the Node child_process IPC functionality in Deno on Unix systems. For `fd > 2` a duplex unix pipe is set up between the parent and child processes. Currently implements data passing via the channel in the JSON serialization format.
2023-12-08chore: use primordials in 40_testing.js (#21422)Divy Srivastava
This commit brings back usage of primordials in "40_testing.js" by turning it back into an ES module and using new "lazy loading" functionality of ES modules coming from "deno_core". The same approach was applied to "40_jupyter.js". Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-02refactor: snapshotting of runtime/ and cli/ (#21430)Bartek Iwańczuk
This commit removes some of the technical debt related to snapshotting JS code: - "cli/ops/mod.rs" and "cli/build.rs" no longer define "cli" extension which was not required anymore - Cargo features for "deno_runtime" crate have been unified in "cli/Cargo.toml" - "cli/build.rs" uses "deno_runtime::snapshot::create_runtime_snapshot" API instead of copy-pasting the code - "cli/js/99_main.js" was completely removed as it's not necessary anymore Towards https://github.com/denoland/deno/issues/21137
2023-11-25feat(unstable): --unstable-unsafe-proto (#21313)David Sherret
Closes https://github.com/denoland/deno/issues/21276
2023-11-25perf: move "cli/js/40_testing.js" out of main snapshot (#21212)Divy Srivastava
Closes https://github.com/denoland/deno/issues/21136 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-22fix: 'Promise was collected' error in REPL/jupyter (#21272)Bartek Iwańczuk
Fixes #20528
2023-11-16fix(npm): support cjs entrypoint in node_modules folder (#21224)David Sherret
Closes #21109
2023-11-15perf: static bootstrap options in snapshot (#21213)Divy Srivastava
Closes https://github.com/denoland/deno/issues/21133
2023-11-14perf: move jupyter esm out of main snapshot (#21163)Divy Srivastava
Towards https://github.com/denoland/deno/issues/21136
2023-11-11perf: snapshot runtime ops (#21127)Divy Srivastava
Closes https://github.com/denoland/deno/issues/21135 ~1ms startup time improvement --------- Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com> Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-11-10perf(cli): strace mode for ops (undocumented) (#21131)Matt Mastracci
Example usage: ``` # Trace every op except op_*tick* cargo run -- run --unstable -A --strace-ops=-tick '/Users/matt/Documents/github/deno/deno/ext/websocket/autobahn/autobahn_server.js # Trace any op matching op_*http* cargo run -- run --unstable -A --strace-ops=http ... ``` Example output: ``` [ 11.478] op_ws_get_buffer : Dispatched Slow [ 11.478] op_ws_get_buffer : Completed Slow [ 11.478] op_ws_send_binary : Dispatched Fast [ 11.478] op_ws_send_binary : Completed Fast [ 11.478] op_ws_next_event : Dispatched Async [ 11.478] op_try_close : Dispatched Fast [ 11.478] op_try_close : Completed Fast [ 11.478] op_timer_handle : Dispatched Fast [ 11.478] op_timer_handle : Completed Fast [ 11.478] op_sleep : Dispatched Asyn ```
2023-11-05chore: migrate to new deno_core and metrics (#21057)Matt Mastracci
- Uses the new OpMetrics system for sync and async calls - Partial revert of #21048 as we moved Array.fromAsync upstream to deno_core
2023-11-01feat: granular --unstable-* flags (#20968)Bartek Iwańczuk
This commit adds granular `--unstable-*` flags: - "--unstable-broadcast-channel" - "--unstable-ffi" - "--unstable-fs" - "--unstable-http" - "--unstable-kv" - "--unstable-net" - "--unstable-worker-options" - "--unstable-cron" These flags are meant to replace a "catch-all" flag - "--unstable", that gives a binary control whether unstable features are enabled or not. The downside of this flag that allowing eg. Deno KV API also enables the FFI API (though the latter is still gated with a permission). These flags can also be specified in `deno.json` file under `unstable` key. Currently, "--unstable" flag works the same way - I will open a follow up PR that will print a warning when using "--unstable" and suggest to use concrete "--unstable-*" flag instead. We plan to phase out "--unstable" completely in Deno 2.
2023-10-31feat: deno run --unstable-hmr (#20876)Bartek Iwańczuk
This commit adds `--unstable-hmr` flag, that enabled Hot Module Replacement. This flag works like `--watch` and accepts the same arguments. If HMR is not possible the process will be restarted instead. Currently HMR is only supported in `deno run` subcommand. Upon HMR a `CustomEvent("hmr")` will be dispatched that contains information which file was changed in its `details` property. --------- Co-authored-by: Valentin Anger <syrupthinker@gryphno.de> Co-authored-by: David Sherret <dsherret@gmail.com>
2023-10-12refactor: FeatureChecker integration in ext/ crates (#20797)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/20779.
2023-10-05refactor(npm): add referrer when resolving npm package sub path from deno ↵David Sherret
module (#20800) Adds a `referrer` parameter to this function instead of using a fake one.
2023-10-03refactor(npm): break up `NpmModuleLoader` and move more methods into the ↵David Sherret
managed `CliNpmResolver` (#20777) Part of https://github.com/denoland/deno/issues/18967
2023-09-29refactor(cli): make `CliNpmResolver` a trait (#20732)David Sherret
This makes `CliNpmResolver` a trait. The terminology used is: - **managed** - Deno manages the node_modules folder and does an auto-install (ex. `ManagedCliNpmResolver`) - **byonm** - "Bring your own node_modules" (ex. `ByonmCliNpmResolver`, which is in this PR, but unimplemented at the moment) Part of #18967
2023-09-28refactor(ext/node): remove dependency on deno_npm and deno_semver (#20718)David Sherret
This is required from BYONM (bring your own node_modules). Part of #18967
2023-09-18fix(cli): for main-module that exists in package.json, use the version ↵await-ovo
defined in package.json directly (#20328)
2023-09-14fix: output traces for op sanitizer in more cases (#20494)Luca Casonato
This adds traces for the "started outside test, closed inside test" case.
2023-08-26chore: update to Rust 1.72 (#20258)林炳权
<!-- 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. --> As the title. --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-21refactor: upgrade deno_ast 0.28 and deno_semver 0.4 (#20193)David Sherret
2023-08-16feat(ext/node): eagerly bootstrap node (#20153)Matt Mastracci
To fix bugs around detection of when node emulation is required, we will just eagerly initialize it. The improvements we make to reduce the impact of the startup time: - [x] Process stdin/stdout/stderr are lazily created - [x] node.js global proxy no longer allocates on each access check - [x] Process checks for `beforeExit` listeners before doing expensive shutdown work - [x] Process should avoid adding global event handlers until listeners are added Benchmarking this PR (`89de7e1ff`) vs main (`41cad2179`) ``` 12:36 $ third_party/prebuilt/mac/hyperfine --warmup 100 -S none './deno-41cad2179 run ./empty.js' './deno-89de7e1ff run ./empty.js' Benchmark 1: ./deno-41cad2179 run ./empty.js Time (mean ± σ): 24.3 ms ± 1.6 ms [User: 16.2 ms, System: 6.0 ms] Range (min … max): 21.1 ms … 29.1 ms 115 runs Benchmark 2: ./deno-89de7e1ff run ./empty.js Time (mean ± σ): 24.0 ms ± 1.4 ms [User: 16.3 ms, System: 5.6 ms] Range (min … max): 21.3 ms … 28.6 ms 126 runs ``` Fixes https://github.com/denoland/deno/issues/20142 Fixes https://github.com/denoland/deno/issues/15826 Fixes https://github.com/denoland/deno/issues/20028
2023-08-06build: allow disabling snapshots for dev (#20048)Nayeem Rahman
Closes #19399 (running without snapshots at all was suggested as an alternative solution). Adds a `__runtime_js_sources` pseudo-private feature to load extension JS sources at runtime for faster development, instead of building and loading snapshots or embedding sources in the binary. Will only work in a development environment obviously. Try running `cargo test --features __runtime_js_sources integration::node_unit_tests::os_test`. Then break some behaviour in `ext/node/polyfills/os.ts` e.g. make `function cpus() {}` return an empty array, and run it again. Fix and then run again. No more build time in between.
2023-08-01feat(npm): support running non-bin scripts in npm pkgs via `deno run` (#19975)David Sherret
Closes https://github.com/denoland/deno/issues/19967
2023-07-02Reland "fix(cli): don't store blob and data urls in the module cache" (#18581)Nayeem Rahman
Relands #18261 now that https://github.com/lucacasonato/esbuild_deno_loader/pull/54 is landed and used by fresh. Fixes #18260.
2023-06-05feat(runtime): support creating workers using custom v8 params (#19339)Mathias Lafeldt
In order to limit the memory usage of isolates via heap_limits.
2023-05-30feat(runtime): add `WorkerLogLevel` (#19316)David Sherret
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-05-22fix(npm): store npm binary command resolution in lockfile (#19219)David Sherret
Part of #19038 Closes #19034 (eliminates the time spent re-resolving)
2023-05-05refactor(ext/node): combine `deno_node::Fs` with `deno_fs::FileSystem` (#18991)David Sherret
2023-05-04refactor(ext/fs): boxed deno_fs::FileSystem (#18945)David Sherret
1. Boxed `File` and `FileSystem` to allow more easily passing this through the CLI code (as shown within this pr). 2. `StdFileResource` is now `FileResource`. `FileResource` now contains an `Rc<dyn File>`.
2023-05-01perf: lazily create RootCertStore (#18938)David Sherret
2023-05-01refactor(cli): remove ProcState - add CliFactory (#18900)David Sherret
This removes `ProcState` and replaces it with a new `CliFactory` which initializes our "service structs" on demand. This isn't a performance improvement at the moment for `deno run`, but might unlock performance improvements in the future.