Bartek Iwańczuk
2929313652
fix(node/http): don't leak resources on destroyed request ( #20040 )
...
Closes https://github.com/denoland/deno/issues/19828
2023-08-29 12:13:58 +00:00
Yoshiya Hinosawa
fb7092fb43
fix(ext/node): fix argv[1] in Worker ( #20305 )
2023-08-29 12:18:25 +09:00
Matt Mastracci
7adaf613bf
fix(ext/node): shared global buffer unlock correctness fix ( #20314 )
...
The fix for #20188 was not entirely correct -- we were unlocking the
global buffer incorrectly. This PR introduces a lock state that ensures
we only unlock a lock we have taken out.
2023-08-28 15:28:39 -06:00
osddeitf
c2547ba039
fix(node/http): correctly send Content-length
header instead of Transfer-Encoding: chunked
( #20127 )
...
Fix #20063 .
2023-08-28 09:32:54 +02:00
Divy Srivastava
1cb547d885
fix(node): propagate create cipher errors ( #20280 )
...
Fixes https://github.com/denoland/deno/issues/19002
2023-08-26 10:45:37 +05:30
Matt Mastracci
c37b9655b6
fix(ext/node): simultaneous reads can leak into each other ( #20223 )
...
Reported in #20188
This was caused by re-use of a global buffer `BUF` during simultaneous
async reads.
2023-08-22 14:45:10 +00:00
Bartek Iwańczuk
a48ec1d563
fix(node/http): emit error when addr in use ( #20200 )
...
Closes https://github.com/denoland/deno/issues/20186
2023-08-18 13:48:18 +02:00
Evan
79d1445796
fix(ext/node): allow for the reassignment of userInfo() on Windows ( #20165 )
...
The goal of this PR is to address issue #20106 where a `TypeError`
occurs when the variables `uid` and `gid` from `userInfo()` in `node:os`
are reassigned if the user is on Windows. Both `uid` and `gid` are
marked as `const` therefore producing a `TypeError` when the two are
reassigned.
This PR achieves that goal by marking `uid` and `gid` as `let`
2023-08-16 11:28:49 +02:00
Matt Mastracci
4380a09a05
feat(ext/node): eagerly bootstrap node ( #20153 )
...
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-16 04:36:36 +09:00
Marcos Casagrande
ddbb5fdfb0
perf(ext/node): optimize http headers ( #20163 )
...
This PR optimizes Node's `IncomingMessageForServer.headers` by replacing
`Object.fromEntries()` with a loop and `headers.entries` with
`headersEntries` which returns the internal array directly instead of an
iterator
## Benchmarks
Using `wrk` with 5 headers
```
wrk -d 10s --latency -H "X-Deno: true" -H "Accept: application/json" -H "X-Foo: bar" -H "User-Agent: wrk" -H "Accept-Encoding: gzip, br" http://127.0.0.1:3000
```
**this PR**
```
Running 10s test @ http://127.0.0.1:3000
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 167.53us 136.89us 2.75ms 97.33%
Req/Sec 31.98k 1.38k 36.39k 70.30%
Latency Distribution
50% 134.00us
75% 191.00us
90% 234.00us
99% 544.00us
642548 requests in 10.10s, 45.96MB read
Requests/sec: 63620.36
Transfer/sec: 4.55MB
```
**main**
```
Running 10s test @ http://127.0.0.1:3000
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 181.31us 132.54us 3.79ms 97.13%
Req/Sec 29.21k 1.45k 32.93k 79.21%
Latency Distribution
50% 148.00us
75% 198.00us
90% 261.00us
99% 545.00us
586939 requests in 10.10s, 41.98MB read
Requests/sec: 58114.01
Transfer/sec: 4.16MB
```
```js
import express from "npm:express";
const app = express();
app.get("/", function (req, res) {
req.headers;
res.end();
});
app.listen(3000);
```
2023-08-15 16:59:35 +02:00
Bartek Iwańczuk
119526a7a5
fix(require): use canonicalized path for loading content ( #20133 )
2023-08-15 09:10:54 +02:00
Marcos Casagrande
e071382768
perf(ext/node): cache IncomingMessageForServer.headers
( #20147 )
...
This PR adds caching to node's `req.headers`
```js
import express from "npm:express";
const app = express();
app.get("/", function (req, res) {
const ua = req.header("User-Agent");
const auth = req.header("Authorization");
const type = req.header("Content-Type");
const ip = req.header("X-Forwarded-For");
res.end();
});
app.listen(3000);
```
**this PR**
```
wrk -d 10s --latency http://127.0.0.1:3000
Running 10s test @ http://127.0.0.1:3000
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 155.64us 152.14us 5.74ms 97.39%
Req/Sec 35.00k 1.97k 39.10k 80.69%
Latency Distribution
50% 123.00us
75% 172.00us
90% 214.00us
99% 563.00us
703420 requests in 10.10s, 50.31MB read
Requests/sec: 69648.45
Transfer/sec: 4.98MB
```
**main**
```
wrk -d 10s --latency http://127.0.0.1:3000
Running 10s test @ http://127.0.0.1:3000
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 217.95us 786.89us 26.26ms 98.23%
Req/Sec 32.32k 2.54k 37.19k 87.13%
Latency Distribution
50% 130.00us
75% 191.00us
90% 232.00us
99% 1.88ms
649411 requests in 10.10s, 46.45MB read
Requests/sec: 64300.44
Transfer/sec: 4.60MB
```
2023-08-14 15:14:02 +02:00
Divy Srivastava
33dc5d2622
fix(node): implement TLSSocket._start ( #20120 )
...
Closes https://github.com/denoland/deno/issues/19983
Closes https://github.com/denoland/deno/issues/18303
Closes https://github.com/denoland/deno/issues/16681
Closes https://github.com/denoland/deno/issues/19978
2023-08-11 11:57:41 +00:00
Divy Srivastava
2f00b0add4
fix(ext/node): support dictionary option in zlib init ( #20035 )
...
Fixes https://github.com/denoland/deno/issues/19540
2023-08-11 11:42:35 +00:00
Divy Srivastava
65db8814c3
fix(node): object keys in publicEncrypt ( #20128 )
...
Fixes https://github.com/denoland/deno/issues/19935
2023-08-11 07:34:23 +00:00
Bartek Iwańczuk
69387f0b0c
fix(node): don't print warning on process.dlopen.flags ( #20124 )
...
Closes https://github.com/denoland/deno/issues/20075
2023-08-10 20:19:20 +02:00
Bartek Iwańczuk
2507d6fa10
fix(node/async_hooks): don't pop async context frame if stack if empty ( #20077 )
...
Closes https://github.com/denoland/deno/issues/20076
2023-08-10 09:00:25 +05:30
David Sherret
a037ed77a2
fix(fmt): do not insert expr stmt leading semi-colon in do while stmt body ( #20093 )
...
This is for when semiColons: false
Closes #20089
2023-08-08 09:15:19 -04:00
Bartek Iwańczuk
6405b5f454
fix(node): polyfill process.title ( #20044 )
...
Closes https://github.com/denoland/deno/issues/19777
2023-08-04 14:31:13 +02:00
Bartek Iwańczuk
8d8a89ceea
fix(node): repl._builtinLibs ( #20046 )
...
Ref https://github.com/denoland/deno/issues/19733
2023-08-04 14:30:48 +02:00
Bartek Iwańczuk
d9c85e016f
fix(node): node:test reports correct location ( #20025 )
...
Also removed some noisy output that caused test flakiness.
2023-08-02 17:11:04 +02:00
Bartek Iwańczuk
21f1b2f62b
feat(node): add polyfill for node:test module ( #20002 )
...
This commit provides basic polyfill for "node:test" module. Currently
only top-level "test" function is polyfilled, all remaining functions from
that module throw not implemented errors.
2023-08-02 01:17:38 +02:00
Leo Kettmeir
aa8078b688
feat(node/os): implement getPriority, setPriority & userInfo ( #19370 )
...
Takes #4202 over
Closes #17850
---------
Co-authored-by: ecyrbe <ecyrbe@gmail.com>
2023-07-31 22:29:09 +02:00
Luca Casonato
78ceeec6be
perf: faster node globals access in cjs ( #19997 )
...
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-31 19:45:32 +00:00
Bartek Iwańczuk
bd79baea5e
fix(node): add writable and readable fields to FakeSocket ( #19931 )
...
Closes https://github.com/denoland/deno/issues/19927
2023-07-25 07:17:53 +00:00
Vedant Pandey
d7a9ed9714
fix(node_compat): Wrap require resolve exports in try catch block ( #19592 )
...
Potentially closes #19499
2023-07-24 11:30:03 +03:00
sigmaSd
5a3dbe1a62
chore: update commonjs loading docs ( #19904 )
2023-07-22 05:48:06 +02:00
Leo Kettmeir
da709729e3
fix(node/http): add encrypted field to FakeSocket ( #19886 )
...
Fixes #19557
2023-07-21 02:18:07 +02:00
Luca Casonato
e511022c74
feat(ext/node): properly segregate node globals ( #19307 )
...
Code run within Deno-mode and Node-mode should have access to a
slightly different set of globals. Previously this was done through a
compile time code-transform for Node-mode, but this is not ideal and has
many edge cases, for example Node's globalThis having a different
identity than Deno's globalThis.
This commit makes the `globalThis` of the entire runtime a semi-proxy.
This proxy returns a different set of globals depending on the caller's
mode. This is not a full proxy, because it is shadowed by "real"
properties on globalThis. This is done to avoid the overhead of a full
proxy for all globalThis operations.
The globals between Deno-mode and Node-mode are now properly segregated.
This means that code running in Deno-mode will not have access to Node's
globals, and vice versa. Deleting a managed global in Deno-mode will
NOT delete the corresponding global in Node-mode, and vice versa.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-07-19 10:30:04 +02:00
Leo Kettmeir
bf4e99cbd7
fix(node/http): call callback after request is sent ( #19871 )
...
Fixes #19762
2023-07-19 01:30:19 +02:00
Leo Kettmeir
bab0294db6
fix(node/net): Server connection callback include socket value ( #19779 )
2023-07-19 00:33:43 +02:00
Divy Srivastava
51b3534b3d
fix(ext/node): check if resource can be used with write_vectored ( #19868 )
...
Fixes https://github.com/denoland/deno/issues/19766
Fixes https://github.com/denoland/deno/issues/19846
2023-07-18 23:34:26 +02:00
Bartek Iwańczuk
7e1218cd8f
fix(node): add process.dlopen API ( #19860 )
...
Fixes https://github.com/denoland/deno/issues/19830
2023-07-18 15:13:17 +02:00
David Sherret
4ebe3bdb06
fix(node): improve error message requiring non-npm es module ( #19856 )
...
Closes #19842
Closes #16913
2023-07-17 16:19:00 -04:00
David Sherret
7a9f7f3419
fix(node): improve require esm error messages ( #19853 )
...
Part of #19842 .
Closes #19583
Closes #16913
2023-07-17 14:00:44 -04:00
await-ovo
37241e9b1e
fix(ext/node): fix stream/promises export ( #19820 )
2023-07-17 22:10:34 +09:00
Leo Kettmeir
9d5f6f67d6
fix(node/http): add destroy to FakeSocket ( #19796 )
...
Closes #19782
2023-07-11 15:08:35 +02:00
Leo Kettmeir
4cfc54931d
fix(node/http): allow callback in first argument of end call ( #19778 )
...
Closes #19762
2023-07-11 14:49:19 +02:00
Leo Kettmeir
5cda141f2d
fix(node/http): server use FakeSocket and add end method ( #19660 )
...
Fixes #19324
2023-07-10 13:48:35 +02:00
David Sherret
f3095b8d31
chore: upgrade to dprint 0.39 ( #19768 )
2023-07-08 18:34:08 +00:00
Divy Srivastava
e4870d84be
perf(ext/node): native vectored write for server streams ( #19752 )
...
```
# main
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 106182.250000
Msg/sec: 110279.750000
^C
# this PR
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 131632.250000
Msg/sec: 134754.250000
^C
```
2023-07-07 22:17:08 +05:30
Bartek Iwańczuk
de630b9b78
perf(node/async_hooks): optimize AsyncLocalStorage ( #19729 )
...
This makes the implementation of "AsyncLocalStorage" from
"node:async_hooks" 3.5x faster than before for noop benchmark
(measuring baseline overhead). It's still 3.5x slower than not
using `AsyncLocalStorage` and 1.64x slower than using
noop promise hooks.
2023-07-06 13:05:10 +02:00
Divy Srivastava
57fae55d82
perf(ext/node): optimize net streams ( #19678 )
...
~4.5x improvement in `npm:ws` echo benchmark:
```
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 101083.750000
Msg/sec: 103606.000000
^C
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 24906.750000
Msg/sec: 28478.000000
^C
```
2023-07-05 22:45:10 +05:30
await-ovo
686ec85f52
fix(ext/node): Define performance.timeOrigin as getter property ( #19714 )
2023-07-04 20:19:18 +03:00
await-ovo
0f4051a37a
fix(ext/node): ignore cancelled timer when node timer refresh ( #19637 )
...
For timers that have already executed clearTimeout, there is no need to recreate a new timer when refresh is executed again.
2023-07-02 19:11:34 +00:00
Bartek Iwańczuk
01f0d03ae8
refactor: rename built-in node modules from ext:deno_node/ to node: ( #19680 )
...
Closes https://github.com/denoland/deno/issues/19510
2023-07-02 20:19:30 +02:00
Leo Kettmeir
4db534d461
fix(node/http): add setKeepAlive to FakeSocket ( #19659 )
...
Closes #19535
2023-06-30 03:39:16 +02:00
Bartek Iwańczuk
f372688f22
fix: lint on main branch ( #19622 )
2023-06-27 17:35:19 +09:00
Kenta Moriuchi
e16b74d792
chore(ext/node): disable prefer-primordials on a per-file basis ( #19553 )
2023-06-27 15:18:22 +09:00
Felipe Baltor
814edcdd57
test(ext/node): port crypto_test.ts from deno_std ( #19561 )
2023-06-27 11:04:49 +09:00