summaryrefslogtreecommitdiff
path: root/runtime/ops
AgeCommit message (Collapse)Author
2024-06-07fix(ext/node): support stdin child_process IPC & fd stdout/stderr (#24106)Divy Srivastava
Add supports for "ipc" and fd options in child_process spawn API. Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to Deno.Command. Used by `node:child_process` Example: ```js const out = fs.openSync("./logfile.txt", 'a') const proc = spawn(process.execPath, ["./main.mjs", "child"], { stdio: ["ipc", out, "inherit"] }); ``` Ref #16753
2024-06-06refactor: remove `PermissionsContainer` in deno_runtime (#24119)David Sherret
Also removes permissions being passed in for node resolution. It was completely useless because we only checked it for reading package.json files, but Deno reading package.json files for resolution is perfectly fine. My guess is this is also a perf improvement because Deno is doing less work.
2024-05-29feat: Add `Deno.exitCode` API (#23609)Luke Edwards
This commits adds the ability to set a would-be exit code for the Deno process without forcing an immediate exit, through the new `Deno.exitCode` API. - **Implements `Deno.exitCode` getter and setter**: Adds support for setting and retrieving a would-be exit code via `Deno.exitCode`. This allows for asynchronous cleanup before process termination without immediately exiting. - **Ensures type safety**: The setter for `Deno.exitCode` validates that the provided value is a number, throwing a TypeError if not, to ensure that only valid exit codes are set. Closes to #23605 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-29fix(ext/node): windows cancel stdin read in line mode (#23969)Divy Srivastava
This patch fixes stdin read hanging on user input when switching tty mode on Windows Fixes #21111 On Windows, when switching from line to raw mode: - Cancel ongoing console read by writing a return keypress to its input buffer. This blocks the main thread until any ongoing read has been cancelled to prevent interference with the screen state. - On the read thread, restore the cursor position to where it was before writing the enter, undoing its effect on the screen state. - Restart reading and notify the main thread.
2024-05-28fix: empty `process.platform` with `__runtime_js_sources` (#24005)Marvin Hagemeister
We use the `target` property of the snapshot options to derive `process.platform` and `process.arch` from. This value had an incorrect format when compiled with `__runtime_js_sources` enabled. This PR fixes that so that `process.platform` holds the proper value. Fixes https://github.com/denoland/deno/issues/23164
2024-05-14fix(runtime): output to stderr with colors if a tty and stdout is piped (#23813)David Sherret
This also fixes a bug where Deno would output to stderr with colours when piped and stdout was not piped.
2024-05-05fix(workers): `importScripts` concurrently and use a new `reqwest::Client` ↵David Sherret
per importScripts (#23699) 1. We were polling each future in sequence, so this meant it was fetching scripts in sequence. 2. It's not safe to share `reqwest::Client` across tokio runtimes (https://github.com/seanmonstar/reqwest/issues/1148#issuecomment-910868788)
2024-04-12chore: upgrade deno_core to 0.274.0 (#23344)Divy Srivastava
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-03-16fix(ext/node): support MessagePort in `WorkerOptions.workerData` (#22950)Bartek Iwańczuk
This commit fixes passing `MessagePort` instances to `WorkerOptions.workerData`. Before they were not serialized and deserialized properly when spawning a worker thread. Closes https://github.com/denoland/deno/issues/22935
2024-03-14fix(cli): unbreak extension example and fix __runtime_js_sources (#22906)Matt Mastracci
Better example to close https://github.com/denoland/deno/issues/22600 --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-03-13fix(ext/node): make worker ids sequential (#22884)Satya Rohith
2024-03-13fix(ext/node): allow automatic worker_thread termination (#22647)Satya Rohith
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-03-12refactor: add `deno_permissions` crate (#22236)Divy Srivastava
Issue https://github.com/denoland/deno/issues/22222 ![image](https://github.com/denoland/deno/assets/34997667/2af8474b-b919-4519-98ce-9d29bc7829f2) This PR moves `runtime/permissions` code to a upstream crate called `deno_permissions`. The `deno_permissions::PermissionsContainer` is put into the OpState and can be used instead of the current trait-based permissions system. For this PR, I've migrated `deno_fetch` to the new crate but kept the rest of the trait-based system as a wrapper of `deno_permissions` crate. Doing the migration all at once is error prone and hard to review. Comparing incremental compile times for `ext/fetch` on Mac M1: | profile | `cargo build --bin deno` | `cargo plonk build --bin deno` | | --------- | ------------- | ------------------- | | `debug` | 20 s | 0.8s | | `release` | 4 mins 12 s | 1.4s |
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-11fix(runtime): Restore default signal handler after user handlers are ↵Nathan Whitaker
unregistered (#22757) <!-- 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 #22724. Fixes #7164. This does add a dependency on `signal-hook`, but it's just a higher level API on top of `signal-hook-registry` (which we and `tokio` already depend on) and doesn't add any transitive deps.
2024-03-06chore: upgrade deno_core (#22725)Nathan Whitaker
<!-- 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. -->
2024-02-18feat(fs): `Deno.FsFile.{isTerminal,setRaw}()` (#22234)Asher Gomez
Closes #22229. --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-02-05Reland refactor(cli): use new sanitizer for resources (#22226)Matt Mastracci
Originally in #22125 Reverted in #22153 because of #22148 Fixed in deno_core https://github.com/denoland/deno_core/pull/538 Test plan: 1. Check out: https://github.com/poolifier/poolifier-deno.git 2. `PATH=.../deno/target/release/:$PATH deno task test` 3. `ok | 13 passed (188 steps) | 0 failed (18s)`
2024-02-05fix(os): total and free memory in bytes (#22247)Divy Srivastava
2024-01-30fix(runtime): return number from `op_ppid` instead of bigint (#22169)Yusuke Tanaka
Fixes #22166
2024-01-24feat: `Deno.{stdin,stdout,stderr}.isTerminal()`, deprecate `Deno.isatty()` ↵Asher Gomez
(#22011) This change: 1. Implements `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` and `Deno.stderr.isTerminal()`. 2. Deprecates `Deno.isatty()` for removal in Deno v2, in favour of the above instance methods. 3. Replaces use of `Deno.isatty()` with the above instance methods. Related #21995 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-23chore: upgrade deno_core to 0.249.0 (#22058)Bartek Iwańczuk
2024-01-23feat: warn when using --unstable, prefer granular flags (#21452)Bartek Iwańczuk
This commit deprecates "--unstable" flag. When "--unstable" flag is encountered a warning like this is printed: ``` The `--unstable` flag is deprecated, use granular `--unstable-*` flags instead. Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags ``` When "--unstable" flag is used and an unstable API is called an additional warning like this is printed for each API call: ``` The `Deno.dlopen` API was used with `--unstable` flag. The `--unstable` flag is deprecated, use granular `--unstable-ffi` instead. Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags ``` When no "--unstable-*" flag is provided and an unstable API is called following warning is issued before exiting: ``` Unstable API 'Deno.dlopen'. The `--unstable-ffi` flag must be provided. ``` --------- Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com> Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com> Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-22feat(unstable): remove Deno.upgradeHttp API (#21856)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/21828. This API is a huge footgun. And given that "Deno.serveHttp" is a deprecated API that is discouraged to use (use "Deno.serve()" instead); it makes no sense to keep this API around. This is a step towards fully migrating to Hyper 1.
2024-01-11fix(web): use rustyline for prompt (#21893)Divy Srivastava
Workaround until https://github.com/kkawakam/rustyline/pull/759
2024-01-10fix: android support (#19437)cions
<!-- 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. --> --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-02Revert "fix(runtime): Make native modal keyboard interaction consistent with ↵Divy Srivastava
browsers" (#21739) Reverts denoland/deno#18453 Fixes https://github.com/denoland/deno/issues/21602 https://github.com/denoland/deno/issues/21631 https://github.com/denoland/deno/issues/21641 Reasons for revert: - alert() and confirm() swallowed ^C with raw mode. - prompt() did not re-raise the interrupt signal from rustyline. - Default 'Y' on confirm() is a bad default and breaking change. cc @lionel-rowe
2024-01-01chore: update to Rust 1.75 (#21731)林炳权
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-27refactor: simplify hyper, http, h2 deps (#21715)Bartek Iwańczuk
Main change is that: - "hyper" has been renamed to "hyper_v014" to signal that it's legacy - "hyper1" has been renamed to "hyper" and should be the default
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-13fix(runtime): Make native modal keyboard interaction consistent with ↵lionel-rowe
browsers (#18453) Fixes https://github.com/denoland/deno/issues/18223. Fixes https://github.com/denoland/deno/issues/21477 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: David Sherret <dsherret@gmail.com>
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-11-30fix(ext/node): fix os.freemem (#21347)Yoshiya Hinosawa
2023-11-20chore: fix `__runtime_js_sources` feature flag (#21265)Divy Srivastava
2023-11-15feat(ext/net): use rustls_tokio_stream (#21205)Matt Mastracci
Fixes #21121 and #19498 Migrates fully to rustls_tokio_stream. We no longer need to maintain our own TlsStream implementation to properly support duplex. This should fix a number of errors with TLS and websockets, HTTP and "other" places where it's failing.
2023-11-15perf: static bootstrap options in snapshot (#21213)Divy Srivastava
Closes https://github.com/denoland/deno/issues/21133
2023-11-15fix(runtime): fix Deno.noColor when stdout is not tty (#21208)Yoshiya Hinosawa
2023-11-13perf: lazy bootstrap options - first pass (#21164)Divy Srivastava
Move most runtime options to be lazily loaded. Constant options will be covered in a different PR. Towards https://github.com/denoland/deno/issues/21133
2023-11-04perf: lazy `atexit` setup (#21053)Divy Srivastava
`libc::atexit` incurrs 2% dyld cost at startup on macOS. This PR moves the setup to when the tty mode is changed using op_stdin_set_raw.
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-28chore: use is_terminal in atty (#21010)Divy Srivastava
2023-10-25chore: update deno_core and port all remaining ops to `op2` (#20954)Bartek Iwańczuk
Signed-off-by: Matt Mastracci <matthew@mastracci.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-10-12refactor: FeatureChecker integration in ext/ crates (#20797)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/20779.
2023-10-07refactor: migrate more ops to op2 macro (#20808)Bartek Iwańczuk
Getting closer...
2023-10-04refactor: rewrite websocket to use op2 macro (#20140)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-04refactor: use deno_core::FeatureChecker for unstable checks (#20765)Bartek Iwańczuk
2023-09-26perf(test): use core.currentUserCallSite (#20669)Luca Casonato
Speeds up `Deno.test` calls by a bit.
2023-09-21refactor: rewrite some ops to op2 macro (#20603)Bartek Iwańczuk
2023-09-18fix: `Deno.Command` - improve error message when `cwd` is not a directory ↵Shreyas
(#20460)