summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
AgeCommit message (Collapse)Author
2023-06-27fix: lint on main branch (#19622)Bartek Iwańczuk
2023-06-27chore(ext/node): disable prefer-primordials on a per-file basis (#19553)Kenta Moriuchi
2023-06-27test(ext/node): port crypto_test.ts from deno_std (#19561)Felipe Baltor
2023-06-26chore: fix typos (#19572)Martin Fischer
2023-06-26fix(ext/node): remove path.toFileUrl (#19536)Ryan Clements
2023-06-24fix(ext/node): support brotli APIs (#19223)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-23fix(serde_v8): Do not coerce values in serde_v8 (#19569)Divy Srivastava
Fixes #19568 Values are not coerced to the desired type during deserialisation. This makes serde_v8 stricter. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-16fix(ext/node): remove fromFileUrl from "node:path" (#19504)Ryan Clements
2023-06-15fix(node): Worker constructor doesn't check type: module of package.json ↵Vedant Pandey
(#19480)
2023-06-15refactor(ext/fetch): simplify fetch ops (#19494)Bartek Iwańczuk
Addresses feedback from https://github.com/denoland/deno/pull/19412#discussion_r1227912676
2023-06-14chore(ext/node): bring back changes to ClientRequest.onSocket (#19509)Leo Kettmeir
Reverts denoland/deno#19426
2023-06-13fix(node/buffer): make slice be the same as subarray (#19481)Leo Kettmeir
2023-06-13fix(ext/node): handle 'upgrade' responses (#19412)Bartek Iwańczuk
This commit adds support for "upgrade" events in "node:http" "ClientRequest". Currently only "Websocket" upgrades are handled. Thanks to this change package like "npm:puppeteer" and "npm:discord" should work. Closes https://github.com/denoland/deno/issues/18913 Closes https://github.com/denoland/deno/issues/17847
2023-06-13feat(node): HTTPS server (#19362)Leo Kettmeir
2023-06-12feat: Adaptations to support OpenBSD port (#19153)VlkrS
2023-06-08chore(ext/node): revert changes to ClientRequest.onSocket (#19426)Bartek Iwańczuk
Partially reverts https://github.com/denoland/deno/pull/19340 because it causes hangs in some situations.
2023-06-08feat(node_compat): Add a write method to the FileHandle class (#19385)nasa
## WHY ref: https://github.com/denoland/deno/issues/19165 The FileHandle class has many missing methods compared to node. ## WHAT Add write method
2023-06-08feat(node_compat): Add a read method to the FileHandle class (#19359)nasa
ref: #19165 The FileHandle class has many missing methods compared to node.
2023-06-06fix(node/http): use fake socket and proper url handling (#19340)Leo Kettmeir
Fixes https://github.com/denoland/deno/issues/19349 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06feat(ext/node): Very basic node:http2 support (#19344)Matt Mastracci
This commit adds basic support for "node:http2" module. Not all APIs have been yet implemented, but this change already allows to use this module for some basic functions. The "grpc" package is still not working, but it's a good stepping stone. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06refactor(core): ensureFastOps is an op-generating proxy (#19377)Matt Mastracci
Startup benchmark shows no changes (within 1ms, identical system/user times).
2023-06-05feat(node_compat): Add a close method to the FileHandle class. (#19357)nasa
## 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-05feat: add more options to Deno.inspect (#19337)Leo Kettmeir
For https://github.com/denoland/deno_std/issues/3404 --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-06-02fix(node): map stdio [0, 1, 2] to "inherit" (#19352)Marvin Hagemeister
<!-- 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-02feat(node_compat): Added base implementation of FileHandle (#19294)nasa
<!-- 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-02fix(node): don't close stdio streams (#19256)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19255 --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-06-01chore(node_compat): add deno task for setting up and running tests (#19293)Hirotaka Tagawa / wafuwafu13
2023-05-31chore(ext/node): Implement stubs for Http2Session (#19329)Matt Mastracci
Fleshes out all the stubs for `node:http2`.
2023-05-31refactor: further work on node http client (#19327)Leo Kettmeir
Closes https://github.com/denoland/deno/issues/18300
2023-05-31fix(node): add missing process.reallyExit method (#19326)Marvin Hagemeister
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()`](https://github.com/tapjs/signal-exit/blob/8fa7fc9a9c63f559af43d292b7eb727901775507/src/index.ts#L19). That function cannot be found anywhere in their documentation, but exists at runtime. See https://github.com/nodejs/node/blob/6a6b3c54022104cc110ab09044a2a0cecb8988e7/lib/internal/bootstrap/node.js#L172 This doesn't yet make `node-tap` work, but gets us one step closer.
2023-05-29fix: use proper ALPN protocols if HTTP client is HTTP/1.1 only (#19303)Bartek Iwańczuk
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-29fix(node): http.IncomingMessageForClient.complete (#19302)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19238
2023-05-27refactor(node/http): don't use readablestream for writing to request (#19282)Leo Kettmeir
Refactors the internal usage of a readablestream to write to the resource directly --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-26refactor(node): use internal io and fs APIs (#19267)Bartek Iwańczuk
2023-05-26fix(node): make 'v8.setFlagsFromString' a noop (#19271)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/16460
2023-05-26chore(node_compat): fix broken link and typo (#19265)Hirotaka Tagawa / wafuwafu13
2023-05-24fix(ext/node): ClientRequest.setTimeout(0) should remove listeners (#19240)Levente Kurusa
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2023-05-24fix(node): fire 'unhandledrejection' event when using node: or npm: imports ↵Bartek Iwańczuk
(#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-23fix(ext/node): add basic node:worker_threads support (#19192)Yoshiya Hinosawa
This PR restores `node:worker_threads` implementation and test cases from [`std@0.175.0/node`](https://github.com/denoland/deno_std/blob/0.175.0/node/worker_threads.ts). --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-23fix(node): duplicate node_module suffixes (#19222)Marvin Hagemeister
Noticed that we're checking more module paths than necessary. In particular the module path array contains a couple of entries with a duplicated `node_modules/node_modules` suffix. ```js [ // ... more entries before here, where some also contain duplicate suffixes "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules/.deno/node_modules", "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules/node_modules", // <-- duplicate suffix "/Users/marvinhagemeister/dev/preact-render-to-string/node_modules", "/Users/marvinhagemeister/dev/node_modules", "/Users/marvinhagemeister/node_modules", "/Users/node_modules", "/node_modules", "/node_modules" // <-- duplicate entry ] ``` This was caused by a misunderstanding in how Rust's [`Path::ends_with()`](https://doc.rust-lang.org/std/path/struct.Path.html#method.ends_with) works. It's designed to match on whole path segments and the suffix `/node_modules` is not that, except for the root entry. This meant that our check for if the path already ended with `node_module` always returned `false`. Removing the leading slash fixes that. While we're at it, we can remove the last condition where we explicitly added the root `/node_modules` entry since the while loop prior to that takes care of it already.
2023-05-23refactor: further work on node http client (#19211)Leo Kettmeir
2023-05-22fix(node): make sure "setImmediate" is not clamped to 4ms (#19213)Bartek Iwańczuk
This commit changes implementation of "setImmediate" from "node:timers" module to 0ms timer that is never clamped to 4ms no matter how many nested calls there are. Closes https://github.com/denoland/deno/issues/19034
2023-05-22fix(node): add http.Server.unref() (#19201)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19113
2023-05-19BREAKING(unstable): change return type of Deno.serve() API (#19189)Bartek Iwańczuk
This commit changes the return type of an unstable `Deno.serve()` API to instead return a `Deno.Server` object that has a `finished` field. This change is done in preparation to be able to ref/unref the HTTP server.
2023-05-18fix(npm): `process` not defined in readline (#19184)Marvin Hagemeister
Issue was that we create node globals much later, so pulling `process` via a module import is the way to go. Fixes #19183
2023-05-18fix(node): support passing parent stdio streams (#19171)Marvin Hagemeister
This is a bit bare bones but gets `npm-run-all` working. For full stdio compatibility with node more work is needed which is probably better done in follow up PRs. Fixes #19159
2023-05-17fix(node): export diagnostics_channel module (#19167)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19166
2023-05-17fix(ext/node): make nodeGlobalThis configurable (#19163)Luca Casonato
2023-05-17fix(ext/node): fix whatwg url formatting (#19146)Yoshiya Hinosawa
2023-05-17refactor(node): reimplement http client (#19122)Leo Kettmeir
This commit reimplements most of "node:http" client APIs using "ext/fetch". There is some duplicated code and two removed Node compat tests that will be fixed in follow up PRs. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>