Commit graph

1037 commits

Author SHA1 Message Date
David Sherret 0e97fa4d5f
fix(npm): only include top level packages in top level node_modules directory (#18824)
We were indeterministically including packages in the top level
`node_modules/` folder when using a local node_modules directory. This
change aligns with pnpm and only includes top level packages in this
folder. This should be faster for initializing the folder, but may
expose issues in packages that reference other packages not defined in
their dependencies. That said, the behaviour previously was previously
broken.

This has exposed a bug in the require implementation where it doesn't
find a package (which is the main underlying issue here). There is a
failing test already for this in the test suite after this change.

Closes #18822

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-24 17:08:11 -04:00
Bartek Iwańczuk 1f0360c073
refactor(ext/node): reorganize ops (#18799)
Move all op related code of "ext/node" to "ext/node/ops" module.

These files were unnecessarily scattered around the extension.
2023-04-24 12:22:21 +02:00
Bartek Iwańczuk 28e2c7204f
chore: remove tokio-tungstenite dependency (#18814) 2023-04-23 23:56:55 -04:00
Matt Mastracci fafb2584ef
refactor(ext/websocket): Remove dep on tungstenite by reworking code (#18812) 2023-04-23 14:07:37 -06:00
Matt Mastracci 13f7f8c415
fix(ext/http): ensure that multiple upgrades and multiple simultaneous requests cannot cause a panic (#18810)
Fix a bug where we weren't saving `slabId` in #18619, plus add some
robustness checks around multiple upgrades (w/test).
2023-04-23 09:59:46 -06:00
Matt Mastracci bdffcb409f
feat(ext/http): Rework Deno.serve using hyper 1.0-rc3 (#18619)
This is a rewrite of the `Deno.serve` API to live on top of hyper
1.0-rc3. The code should be more maintainable long-term, and avoids some
of the slower mpsc patterns that made the older code less efficient than
it could have been.

Missing features:

- `upgradeHttp` and `upgradeHttpRaw` (`upgradeWebSocket` is available,
however).
- Automatic compression is unavailable on responses.
2023-04-22 11:48:21 -06:00
Levente Kurusa d137501a63
feat(node/http): implement ClientRequest.setTimeout() (#18783)
- implement setTimeout with matching semantics of Node
- add the test from Node but leave it turned off because ClientRequest
has no underlying socket
2023-04-22 13:20:00 +02:00
Bartek Iwańczuk 068228cb45
refactor: rewrite tests to "fastwebsockets" crate (#18781)
Migrating off of `tokio-tungstenite` crate.

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-22 11:17:31 +02:00
David Sherret a615eb3b56
refactor(node): move most of cli/node to ext/node (#18797)
This is just a straight refactor and I didn't do any cleanup in
ext/node. After this PR we can start to clean it up and make things
private that don't need to be public anymore.
2023-04-21 21:02:46 -04:00
David Sherret 4a33c349af
refactor: move some CJS and ESM code analysis to ext/node (#18789) 2023-04-21 16:38:10 -04:00
Divy Srivastava 4e944dea1d
fix(ext/websocket): upgrade fastwebsockets to 0.2.4 (#18791)
Fixes https://github.com/denoland/deno/issues/18775
2023-04-21 08:55:02 +02:00
Divy Srivastava 1976504c63
refactor(ext/websocket): use fastwebsockets client (#18725) 2023-04-20 21:54:22 +05:30
Yoshiya Hinosawa f520284081
refactor(ext/node): remove polyfills/_core.ts (#18766) 2023-04-20 13:24:28 +09:00
Bartek Iwańczuk 02da57e275
refactor(ext/webidl): remove option bags from "makeException" (#18679)
Creating these options bags is more costly than passing arguments
one-by-one. Especially since `prefix` and `context` are passed to all functions.
2023-04-20 00:58:41 +02:00
Divy Srivastava 9496dfc685
fix(ext/node): implement asymmetric keygen (#18651)
Towards #18455 

This commit implements the keypair generation for asymmetric keys for
the `generateKeyPair` API.

See how key material is managed in this implementation:
https://www.notion.so/denolandinc/node-crypto-design-99fc33f568d24e47a5e4b36002c5325d?pvs=4

Private and public key encoding depend on `KeyObject#export` which is
not implemented. I've also skipped ED448 and X448 since we need a crate
for that in WebCrypto too.
2023-04-19 22:27:34 +05:30
Yoshiya Hinosawa 53c9f5918c
fix(ext/node): improve vm.runInThisContext (#18767) 2023-04-19 23:26:16 +09:00
Yoshiya Hinosawa fdebb7e793
fix(ext/node): add crypto.sign|verify methods (#18765) 2023-04-19 23:24:26 +09:00
Bartek Iwańczuk 36cfb2fdbb
tests: deflake 'check_sockopt' (#18763)
This function was inherently racy which showed on slow machines -
the connect future started before the spawned task was first polled.

This change makes it so we're already accepting a connection when
the connect future is first polled.
2023-04-19 14:20:30 +02:00
Bartek Iwańczuk b7e19134b8
test: fix flaky tcp tests (#18755)
https://github.com/denoland/deno/actions/runs/4734473301/jobs/8403453096?pr=18749
2023-04-18 23:22:47 +02:00
denobot 4e5d370b56
chore: forward v1.32.5 release commit to main (#18758)
Co-authored-by: levex <levex@users.noreply.github.com>
Co-authored-by: Levente Kurusa <lkurusa@kernelstuff.org>
2023-04-18 22:20:49 +02:00
Levente Kurusa 530963c34c
refactor(node/crypto): scrypt polyfill to rust (#18746) 2023-04-18 14:29:10 +02:00
Yoshiya Hinosawa 5f44396a9e
fix(ext/node): implement crypto.createVerify (#18703) 2023-04-18 21:04:51 +09:00
Ryan Clements b0b0594767
fix(path): Remove non node symbols (#18630)
- preserve referential invariants (e.g. path.posix === posix)
- remove glob and separator exports
- save removal of fromFileUrl and toFileUrl for a different PR as that
refactor is more involved
- addresses #18177
2023-04-18 10:44:25 +02:00
Yoshiya Hinosawa de21a780fd
fix(ext/node): add req.socket.remoteAddress (#18733) 2023-04-18 16:00:51 +09:00
Yoshiya Hinosawa 6efaef606a
fix(ext/node): polyfill response._implicitHeader method (#18738) 2023-04-18 15:20:36 +09:00
Luca Casonato bcbdaac7e6
chore(ext/fs): decouple fs trait from deno_core (#18732)
This commit removes the dependencies on `deno_core` for the Fs trait.
This allows to move the trait into a different crate that does not
depend on core in the limit.

This adds a new `bounds` field to `deno_core::extension!` that expands
to `where` clauses on the generated code. This allows to add bounds to
the extension parameters, such as `Fs::File: Resource`.
2023-04-17 16:10:59 +02:00
Bartek Iwańczuk f191dd8609
test: don't silently fail in check_sockopt (#18737) 2023-04-17 09:41:28 -04:00
Ryan Dahl 2184103a5e
feat(kv): AtomicOperation#sum (#18704) 2023-04-15 10:33:31 +02:00
Kenta Moriuchi f086ec57b4
fix(core): Use safe primordials wrappers (#18687) 2023-04-14 22:23:28 +02:00
Divy Srivastava a411144219
fix(ext/websocket): Avoid write deadlock that requires read_frame to complete (#18705)
Fixes https://github.com/denoland/deno/issues/18700

Timeline of the events that lead to the bug.

1. WebSocket handshake complete
2. Server on `read_frame` holding an AsyncRefCell borrow of the
WebSocket stream.
3. Client sends a TXT frame after a some time
4. Server recieves the frame and goes back to `read_frame`.
5. After some time, Server starts a `write_frame` but `read_frame` is
still holding a borrow!
^--- Locked. read_frame needs to complete so we can resume the write.

This commit changes all writes to directly borrow the
`fastwebsocket::WebSocket` resource under the assumption that it won't
affect ongoing reads.
2023-04-14 22:17:39 +05:30
Divy Srivastava 738bdebe13
chore: bump fastwebsockets to 0.1.3 (#18684)
Fixes build on aarch64 Linux. See
https://github.com/littledivy/fastwebsockets/issues/2
2023-04-13 13:16:19 +00:00
Yiyu Lin d790ea7d53
refactor(cli,ext,ops): cleanup regex with lazy-regex (#17296)
- bump deps: the newest `lazy-regex` need newer `oncecell` and
`regex`
- reduce `unwrap`
- remove dep `lazy_static`
- make more regex cached

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-13 03:08:01 +02:00
Divy Srivastava 659d1dd7f8
perf(ext/websocket): make op_server_ws_next_event deferred (#18632)
Avoid attempting to read immediately, wasting time polling the future.
2% throughput improvement on Linux.
2023-04-13 00:51:47 +02:00
Bartek Iwańczuk a3c5193a2e
refactor(ext/webidl): remove object from 'requiredArguments' (#18674)
This should produce a little less garbage and using an object here
wasn't really required.

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2023-04-12 19:58:57 +00:00
David Sherret 66a22d231a
chore: fix windows clippy errors (#18670) 2023-04-12 13:13:06 -04:00
denobot 05c393b99b
chore: forward v1.32.4 release commit to main (#18669)
Co-authored-by: levex <levex@users.noreply.github.com>
2023-04-12 13:03:27 -04:00
Luca Casonato f90caa821c
refactor(ext/fs): abstract FS via FileSystem trait (#18599)
This commit abstracts out the specifics of the underlying system calls
FS operations behind a new `FileSystem` and `File` trait in the
`ext/fs` extension.

This allows other embedders to re-use ext/fs, but substituting in a
different FS backend.

This is likely not the final form of these traits. Eventually they will
be entirely `deno_core::Resource` agnostic, and will live in a seperate
crate.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-12 15:13:32 +02:00
Satya Rohith 18e0ee368c
fix(ext/cache): cache.put overwrites previous call (#18649) 2023-04-12 11:25:19 +05:30
Levente Kurusa 65b0d2316d
refactor(node/crypto): port polyfill to Rust for randomInt, randomFill, randomFillSync (#18658)
Pretty much as per the title, I'd welcome some feedback especially
around the
array/buffer handling in the two randomFill functions.
2023-04-12 02:57:57 +02:00
Luca Casonato e0bf8e6faf
fix(ext/kv): keys must be arrays (#18655)
There was some leftover code from previous iterations, where keys could
be single parts instead of arrays also. This didn't match the types.
2023-04-11 14:36:01 +00:00
David Sherret 25aac6c7a8
chore: fix linting on main (#18633) 2023-04-07 20:26:39 +00:00
Divy Srivastava a0dd0cbcb9
fix(ext/node): add X509Certificate (#18625)
Towards #18455
2023-04-07 22:54:16 +05:30
Bartek Iwańczuk 5d9172467e
refactor(ext/node): remove conditional in ServerResponse#enqueue (#18617)
It's superfluous, the issue linked is no longer relevant.

Closes https://github.com/denoland/deno/issues/18579
2023-04-07 13:10:05 +09:00
Divy Srivastava df72420d72
fix(ext/node): implement hkdf-expand (#18612)
Towards https://github.com/denoland/deno/issues/18455
2023-04-06 16:56:56 +00:00
David Sherret 2d0a9ffbcc
refactor(ext/node): NodeFs - add back altered metadata method (#18613)
From https://github.com/denoland/deno/pull/18604/files#r1159992299

We should still have a `metadata` method because it's one system call
instead of two on most platforms.
2023-04-06 16:53:53 +00:00
Marvin Hagemeister e51985ca74
fix(ext/node): fix unable to resolve fraction.js (#18544)
Turns out `autoprefixer` is a better reproduction case then
`microbundle`.

Fixes #18535 
Fixes #18600

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-06 16:12:50 +02:00
Divy Srivastava 4cc8784f5b
perf(ext/websocket): replace tokio_tungstenite server with fastwebsockets (#18587)
https://github.com/littledivy/fastwebsockets

```
# This PR
./load_test 100 0.0.0.0 8080 0 0
Running benchmark now...
Msg/sec: 176355.000000

# main
./load_test 100 0.0.0.0 8080 0 0
Running benchmark now...
Msg/sec: 157198.750000
```
2023-04-06 18:44:31 +05:30
Divy Srivastava 3b62a58818
fix(ext/node): add symmetric keygen (#18609)
Towards #18455
2023-04-06 18:39:25 +05:30
Bartek Iwańczuk 339165bd95
refactor(ext/node): add more methods to 'NodeFs' trait (#18604)
Added more methods to `ext/node/clippy.toml` that are not allowed
to be used in the crate.

Prerequisite for https://github.com/denoland/deno/pull/18544
2023-04-06 15:08:14 +02:00
Geert-Jan Zwiers a7e25b8126
fix(ext/node): json encode binary command name (#18596)
Fixes https://github.com/denoland/deno/issues/18588
2023-04-06 01:46:21 +02:00