summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
AgeCommit message (Collapse)Author
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-19fix(console): inspect for `{Set,Map}Iterator` and `Weak{Set,Map}` (#21554)Kenta Moriuchi
2023-12-15refactor: setup child process pipe in Rust (#21579)Divy Srivastava
Avoid passing the fd into JS and back into Rust. Instead we setup the child's end of the pipe directly using a special Rust op.
2023-12-14chore(node): remove process.on("disconnect") not implemented warning (#21569)Divy Srivastava
2023-12-14fix(node): return false from vm.isContext (#21568)Divy Srivastava
https://github.com/denoland/deno/issues/20851#issuecomment-1779226106 for `jsdom`
2023-12-13fix(zlib): handle no flush flag in handle_.write (#21432)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/21096
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-11fix(ext/node): basic vm.runInNewContext implementation (#21527)Divy Srivastava
Simple implementation to support webpack (& Next.js): https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/javascript/JavascriptParser.js#L4329
2023-12-11fix(ext/node): ServerResponse getHeader() return undefined (#21525)Divy Srivastava
Matches Node's return type. Next.js check for `if (header === undefined)`: https://github.com/vercel/next.js/blob/e02fe314dcd0ae614c65b505c6daafbdeebb920e/packages/next/src/server/base-http/node.ts#L93
2023-12-11fix(ext/node): stub ServerResponse#flushHeaders (#21526)Divy Srivastava
This commit adds a no-op flushHeaders method to the ServerResponse object. It is a nop because the ServerResponse implementation is based on top of the Deno server API instead of the Node `OutgoingMessage` base. Fixes #21509
2023-12-08fix(ext/node): use primordials in ext/node/polyfills/_util (#21444)Kenta Moriuchi
2023-12-08fix(ext/node): allow null value for req.setHeader (#21391)Yoshiya Hinosawa
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-08fix(node/tls): fix NotValidForName for host set via socket / servername (#21441)Max Goodhart
This PR is an attempt to fix https://github.com/denoland/deno/issues/20293, in which node modules connecting to databases fail due to TLS errors. I ran into this attempting to use [node-postgres](https://github.com/brianc/node-postgres) to connect to a [Neon](https://neon.tech) database. Investigating via `--inspect-brk` led me to notice that the hostname eventually passed to `Deno.startTls` was null. The hostname is determined by the following code: https://github.com/denoland/deno/blob/f6b889b43219e3c9be770c8b2758bff3048ddcbd/ext/node/polyfills/_tls_wrap.ts#L87-L89 This logic doesn't appear to be correct. I couldn't find reference to `servername` existing on the `secureContext` in either Node's or Deno's docs. There's a lot of scope here, and it's my first time reading through this code, so I could be missing something! Node uses [the following logic](https://github.com/nodejs/node/blob/2e458d973638d01fcb6a0d7d611e0120a94f4d35/lib/_tls_wrap.js#L1679-L1682 ) to determine the hostname for certificate validation: ``` const hostname = options.servername || options.host || (options.socket && options.socket._host) || 'localhost'; ``` This PR updates the `TLSSocket` polyfill to use behave similarly (though I omitted the default to `localhost` at the end; I'm not sure if including it is necessary or correct). With this change, `node-postgres` connects to my TLS endpoint successfully (aside: Neon requires SNI, which also works as expected). --- I tried to update the tests in https://github.com/denoland/deno/blob/main/cli/tests/unit_node/tls_test.ts to exercise this change, but the test fails for me on `main` on Linux. I investigated briefly and noticed that the test fixture `cli/tests/testdata/tls/localhost.crt` doesn't appear to include the `subjectAltName` specified in `domains.txt`. I believe the certificate isn't matching `localhost`, but that's where I ended investigating.
2023-12-07refactor: pull 'core', 'internals', 'primordials' from ES module (#21462)Bartek Iwańczuk
This commit refactors how we access "core", "internals" and "primordials" objects coming from `deno_core`, in our internal JavaScript code. Instead of capturing them from "globalThis.__bootstrap" namespace, we import them from recently added "ext:core/mod.js" file.
2023-12-04perf(node/fs): faster `existsSync` when not exists (#21458)David Sherret
2023-12-03fix(ext/node): sign with PEM private keys (#21287)Divy Srivastava
Add support for signing with a RSA PEM private key: `pkcs8` and `pkcs1`. Fixes https://github.com/denoland/deno/issues/18972 Ref #21124 Verified fix with `npm:sshpk`. Unverfied but fixes `npm:google-auth-library`, `npm:web-push` & `oracle/oci-typescript-sdk` --------- Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-12-02fix(node): setting process.exitCode should change exit code of process (#21429)David Sherret
2023-12-02chore: update std to 0.208.0 (#21318)Asher Gomez
Re-attempt at #21284. I was more thorough this time. --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-12-01refactor: use resourceForReadableStream for fetch (#20217)Matt Mastracci
Switch `ext/fetch` over to `resourceForReadableStream` to simplify and unify implementation with `ext/serve`. This allows us to work in Rust with resources only. Two additional changes made to `resourceForReadableStream` were required: - Add an optional length to `resourceForReadableStream` which translates to `size_hint` - Fix a bug where writing to a closed stream that was full would panic
2023-12-01fix(ext/node): add stubbed process.report (#21373)Daniel Mizerski
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-11-30fix(ext/node): fix os.freemem (#21347)Yoshiya Hinosawa
2023-11-29fix(ext/node): add util.parseArgs (#21342)Yoshiya Hinosawa
2023-11-28Reland "fix(ext/console): fix inspecting iterators error. (#20720)" (#21370)Leo Kettmeir
2023-11-28fix(ext/node): fix Buffer.copy when sourceStart > source.length (#21345)Yoshiya Hinosawa
2023-11-28fix(ext/node): fix duplexify compatibility (#21346)Yoshiya Hinosawa
2023-11-27fix(node): `spawnSync`'s `status` was incorrect (#21359)David Sherret
The exit code wasn't hooked up properly.
2023-11-23fix(ext/node): fix node:stream.Writable (#21297)Yoshiya Hinosawa
This change applies the same fix as https://github.com/nodejs/node/pull/46818, and the original example given in #20456 works as expected. closes #20456
2023-11-22refactor: replace `deferred()` from `std/async` with ↵Asher Gomez
`Promise.withResolvers()` (#21234) Closes #21041 --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-11-14fix(ext/node): add APIs perf_hook.performance (#21192)Bartek Iwańczuk
Required for Next.js.
2023-11-13Revert "fix(ext/console): fix inspecting iterators error. (#20720)" (#21191)Bartek Iwańczuk
This reverts commit 0209f7b46954d1b7bf923b4191e5a356ec09622c. Reverting because it causes failures on `main`: https://github.com/denoland/deno/pull/20720#issuecomment-1809166755
2023-11-13fix(ext/console): fix inspecting iterators error. (#20720)Chen Su
Fixes #19776 and #20676.
2023-11-11fix(node/http): export globalAgent (#21081)Jacob Hummer
Fixes #21080 Fixes #18312 --------- Signed-off-by: Jacob Hummer <jcbhmr@outlook.com>
2023-11-10fix(ext/node): implement process.geteuid (#21151)Divy Srivastava
Fixes #21097
2023-11-10fix(node/child_process): properly normalize stdio for 'spawnSync' (#21103)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/20782
2023-11-09perf: remove knowledge of promise IDs from deno (#21132)Matt Mastracci
We can move all promise ID knowledge to deno_core, allowing us to better experiment with promise implementation in deno_core. `{un,}refOpPromise(promise)` is equivalent to `{un,}refOp(promise[promiseIdSymbol])`
2023-11-09fix(node): implement createPrivateKey (#20981)Divy Srivastava
Towards #18455
2023-11-07fix(node/http): socket.setTimeout (#20930)Gasman
Fixes #20923
2023-11-06fix(ext): use `String#toWellFormed` in ext/webidl and ext/node (#21054)Kenta Moriuchi
Fixes #18802 This PR adds `util.toUSVString` to node:util: ```js import util from "node:util"; util.toUSVString("string\ud801"); // => "string\ufffd" ```
2023-11-04fix(node): use closest package.json to resolve package.json imports (#21075)David Sherret
2023-11-01fix(ext/node): adapt dynamic type checking to Node.js behavior (#21014)Kenta Moriuchi
2023-10-31fix(ext/node): tty streams extends net socket (#21026)Divy Srivastava
Workaround the circular references issue by using a initializer function to give tty stream class to `initStdin`. Fixes https://github.com/denoland/deno/issues/21024 Fixes https://github.com/denoland/deno/issues/20611 Fixes https://github.com/denoland/deno/issues/20890 Fixes https://github.com/denoland/deno/issues/20336 `create-svelte` works now: ``` divy@mini /t/a> ~/gh/deno/target/debug/deno run -A --unstable --reload npm:create-svelte@latest sveltekit-deno create-svelte version 5.1.1 ┌ Welcome to SvelteKit! │ ◇ Which Svelte app template? │ Skeleton project │ ◇ Add type checking with TypeScript? │ Yes, using JavaScript with JSDoc comments │ ◇ Select additional options (use arrow keys/space bar) │ none │ └ Your project is ready! ✔ Type-checked JavaScript https://www.typescriptlang.org/tsconfig#checkJs Install community-maintained integrations: https://github.com/svelte-add/svelte-add Next steps: 1: cd sveltekit-deno 2: npm install 3: git init && git add -A && git commit -m "Initial commit" (optional) 4: npm run dev -- --open To close the dev server, hit Ctrl-C Stuck? Visit us at https://svelte.dev/chat ``` --------- Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-10-30fix: implement node:tty (#20892)Divy Srivastava
Fixes #21012 Closes https://github.com/denoland/deno/issues/20855 Fixes https://github.com/denoland/deno/issues/20890 Fixes https://github.com/denoland/deno/issues/20611 Fixes https://github.com/denoland/deno/issues/20336 Fixes `create-svelte` from https://github.com/denoland/deno/issues/17248 Fixes more reports here: - https://github.com/denoland/deno/issues/6529#issuecomment-1432690559 - https://github.com/denoland/deno/issues/6529#issuecomment-1522059006 - https://github.com/denoland/deno/issues/6529#issuecomment-1695803570
2023-10-22fix(polyfill): correctly handle flag when its equal 0 (#20953)sigmaSd
Fixes https://github.com/denoland/deno/issues/20910
2023-10-18fix(ext/node): process.argv0 (#20925)Bartek Iwańczuk
Fixes https://github.com/denoland/deno/issues/20924
2023-10-12fix(node/http2): fixes to support grpc (#20712)Bartek Iwańczuk
This commit improves "node:http2" module implementation, by enabling to use "options.createConnection" callback when starting an HTTP2 session. This change enables to pass basic client-side test with "grpc-js/grpc" package. Smaller fixes like "Http2Session.unref()" and "Http2Session.setTimeout()" were handled as well. Fixes #16647
2023-10-08fix(node/buffer): utf8ToBytes should return a Uint8Array (#20769)Aapo Alasuutari
2023-10-05fix(ext/node): implement uv.errname (#20785)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/20617
2023-10-02fix(ext/node): don't call undefined nextTick fn (#20724)Luca Casonato
The `process` global is not defined in this file. Fixes #20441 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-09-30perf(node): use faster utf8 byte length in Buffer#from (#20746)Divy Srivastava
Use the `core.byteLength` op for string utf8 length calculation in `node:buffer` ``` # This patch file:///Users/divy/gh/deno/buffer.mjs benchmark time (avg) iter/s (min … max) p75 p99 p995 ----------------------------------------------------------------- ----------------------------- Buffer#from 272.11 ns/iter 3,675,029.3 (268.41 ns … 301.15 ns) 271.62 ns 295.5 ns 301.15 ns # Deno 1.37.1 file:///Users/divy/gh/deno/buffer.mjs benchmark time (avg) iter/s (min … max) p75 p99 p995 ----------------------------------------------------------------- ----------------------------- Buffer#from 411.28 ns/iter 2,431,428.8 (393.82 ns … 439.92 ns) 418.85 ns 434.4 ns 439.92 ns ```
2023-09-30feat(node/os): Add `availableParallelism` (#20745)Rui He