Commit graph

723 commits

Author SHA1 Message Date
David Sherret d3299c2d6c
fix(npm): don't resolve JS files when resolving types (#16854)
Closes #16851
2022-11-28 17:48:56 -05:00
Bartek Iwańczuk fd51b2e506
fix(npm): allow to inspect npm modules with --inspect-brk (#16841) 2022-11-28 21:59:36 +01:00
Aapo Alasuutari a4dfc6f955
fix(ext/ffi): Null buffer pointer value is inconsistent (#16625)
Currently, slow call path will always create a dangling pointer to
replace a null pointer when called with eg. a `new Uint8Array()`
parameter, which V8 initialises as a null pointer backed buffer.

However, the fast call path will never change the pointer value and will
thus expose a null pointer. Thus, it's possible that the pointer value
that a native call sees coming from Deno changes between two sequential
invocations of the same function with the exact same parameters.

Since null pointers can be quite important, and `Uint8Array` is the
chosen fast path for Deno FFI `"buffer"` parameters, I think it is
fairly important that the null pointer be properly exposed to the native
code. Thus this PR.

### `*mut c_void`
While here, I also changed the type of our pointer values to `*mut
c_void`. This is mainly due to JS buffers always being `*mut`, and
because we offer a way to turn a pointer into a JS `ArrayBuffer`
(`op_ffi_get_buf`) which is read-write. I'm not exactly sure which way
we should really go here, we have pointers that are definitely mut but
we also cannot assume all of our pointers are. So, do we go with the
maxima or the minima?

### `optimisedCall(new Uint8Array())`
V8 seems to have a bug where calling an optimised function with a newly
created empty `Uint8Array` (no argument or 0) will not see the data
pointer being null but instead it's some stable pointer, perhaps
pointing to some internal null-backing-store. The pointer value is also
an odd (not even) number, so it might specifically be a tagged pointer.

This will probably be an issue for some users, if they try to use eg.
`method(cstr("something"), new Uint8Array())` as a way to do a fast call
to `method` with a null pointer as the second parameter.

If instead of a `new Uint8Array()` the user instead uses some `const
NULL = new Uint8Array()` where the `NULL` buffer has been passed to a
slow call previously, then the fast call will properly see a null
pointer.

I'll take this up with some V8 engineers to see if this couldn't be
fixed.
2022-11-27 14:38:54 +00:00
Divy Srivastava 9ffc6acdbb
perf(ops): Reenable fast unit result optimization (#16827)
The optimization was missed in the optimizer rewrite
https://github.com/denoland/deno/pull/16514
2022-11-27 04:48:17 +00:00
Bartek Iwańczuk 0012484f4f
Revert "fix(ext/flash): graceful server startup/shutdown with unsettl… (#16839)
…ed promises in mind (#16616)"

This reverts commit fd023cf793.

There are reports saying that Vite is often hanging in 1.28.2 and this
is
the only PR that changed something with HTTP server. I think we should
hold off on trying to fix this and instead focus on #16787

CC @magurotuna
2022-11-27 04:50:14 +01:00
Divy Srivastava fcdcc8c0c3
feat(ops): support raw pointer arguments (#16826)
See https://github.com/denoland/deno/pull/16814#discussion_r1032744083.
Allows nullable buffers in low-level ops like FFI:

```rust
fn op_ffi_ptr_of<FP>(
  state: &mut OpState,
  buf: *const u8,
  out: &mut [u32],
) 
where
  FP: FfiPermissions + 'static {
  // ..
}
```
2022-11-26 20:07:43 +05:30
denobot 72dd7ad807
chore: forward v1.28.2 release commit to main (#16796)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-11-24 23:59:42 +01:00
David Sherret 823a5f6015
fix(npm/types): resolve main entrypoint declaration file when no types entry (#16791)
Closes #16782
2022-11-24 19:13:51 +01:00
Yusuke Tanaka fd023cf793
fix(ext/flash): graceful server startup/shutdown with unsettled promises in mind (#16616)
This PR resets the revert commit made by #16610, bringing back #16383
which attempts to fix the issue happening when we use the flash server
with `--watch` option enabled.
Also, some code changes are made to pass the regression test added in
#16610.
2022-11-24 18:38:09 +01:00
Leo Kettmeir 13e3acf71d
chore: workspace inheritance (#16343) 2022-11-22 21:07:35 +01:00
Divy Srivastava ef82211377
Reland "perf(ext/flash): optimize response streaming" (#16660) 2022-11-22 16:23:58 +05:30
Bartek Iwańczuk 1ec357faf3
fix(inspector): ensure console methods provided by inspector are available (#16724) 2022-11-22 02:17:14 +01:00
Bartek Iwańczuk c0482e09c3
Revert "fix(ext/websocket): make try_send ops infallible (#16454)" (#16743)
This reverts commit d76014192d.
2022-11-21 16:23:47 +01:00
David Sherret a57134de38
fix(npm): handle directory resolution when resolving declaration files (#16706)
Also fixes resolving specifiers like `./something.generated` in
declaration files.

Closes #16695
2022-11-19 10:40:01 -05:00
Yoshiya Hinosawa 7ab08130a0
fix(ext/node): handle URL in createRequire (#16682) 2022-11-19 20:32:39 +09:00
Aaron O'Mullan 238590aa9f
chore: use Rust 1.65.0 (#16688) 2022-11-18 02:59:10 +01:00
denobot 483c10c94b
chore: forward v1.28.1 release commit to main (#16678)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2022-11-17 02:17:19 +01:00
Bartek Iwańczuk 1416713cb3
fix(npm): using types for packages with subpath (#16656)
For CommonJS packages we were not trying different extensions for files
specified as subpath of the package ([package_name]/[subpath]). 
This commit fixes that.
2022-11-16 20:41:27 +01:00
Marcos Casagrande 0832ba1deb
perf(runtime/spawn): collect output using op_read_all (#16596)
**This patch**
```
benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
echo deno   23.99 ms/iter   (22.51 ms … 33.61 ms)  23.97 ms  33.61 ms  33.61 ms
cat 16kb    24.27 ms/iter    (22.5 ms … 35.21 ms)   24.2 ms  35.21 ms  35.21 ms
cat 1mb     25.88 ms/iter   (25.04 ms … 30.28 ms)  26.12 ms  30.28 ms  30.28 ms
cat 15mb    38.41 ms/iter       (35.7 ms … 50 ms)  38.31 ms     50 ms     50 ms
```

**main**
```
benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
echo deno   35.66 ms/iter   (34.53 ms … 41.84 ms)  35.79 ms  41.84 ms  41.84 ms
cat 16kb    35.99 ms/iter   (34.52 ms … 44.94 ms)  36.05 ms  44.94 ms  44.94 ms
cat 1mb     38.68 ms/iter   (36.67 ms … 50.44 ms)  37.95 ms  50.44 ms  50.44 ms
cat 15mb     48.4 ms/iter   (46.19 ms … 58.41 ms)  49.16 ms  58.41 ms  58.41 ms
```
2022-11-15 14:06:52 +01:00
denobot 916598f8a7
1.28.0 (#16620)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-11-13 15:31:36 -05:00
Yoshiya Hinosawa 336e96a114
fix(ext/flash): revert #16383 (graceful server startup/shutdown) (#16610)
#16383 made some of Node compat test cases flaky in deno_std (and when
it fails it causes segfaults).

See https://github.com/denoland/deno_std/issues/2882 for details
2022-11-13 17:35:28 +09:00
Bartek Iwańczuk b88b7c9244
chore: upgrade rusty_v8 to 0.55.0 (#16604)
<!--
Before submitting a PR, please read http://deno.land/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.
-->
2022-11-12 05:37:37 +01:00
Divy Srivastava 38f0b41e7d
perf(web): optimize single pass utf8 decoding (#16593)
- [x] Avoid copying buffers.

https://encoding.spec.whatwg.org/#dom-textdecoder-decode

> Implementations are strongly encouraged to use an implementation
strategy that avoids this copy. When doing so they will have to make
sure that changes to input do not affect future calls to
[decode()](https://encoding.spec.whatwg.org/#dom-textdecoder-decode).

- [x] Special op to avoid string label deserialization and parsing.
(Ideally we should map labels to integers in JS)
- [x] Avoid webidl `Object.assign` when options is undefined.
2022-11-11 20:07:18 +05:30
Divy Srivastava ff92febb38
fix(ext/flash): graceful server startup/shutdown (#16383)
Fixes https://github.com/denoland/deno/issues/16267

Co-authored-by: Yusuke Tanaka <yusuktan@maguro.dev>
2022-11-11 19:11:52 +05:30
Bartek Iwańczuk 8d5c0112fb
feat: don't require --unstable flag for npm programs (#16520)
This PR adds copies of several unstable APIs that are available
in "Deno[Deno.internal].nodeUnstable" namespace.

These copies do not perform unstable check (ie. don't require
"--unstable" flag to be present). Otherwise they work exactly
the same, including permission checks.

These APIs are not meant to be used by users directly and
can change at any time.

Copies of following APIs are available in that namespace:
- Deno.spawnChild
- Deno.spawn
- Deno.spawnSync
- Deno.serve
- Deno.upgradeHttpRaw
- Deno.listenDatagram
2022-11-10 22:03:28 +01:00
Bartek Iwańczuk 53e974b276
feat: remove --unstable flag requirement for npm: specifiers (#16473)
This commit makes "npm:" specifiers not require "--unstable" flag.
At the moment some APIs used by Node polyfills still require
"--unstable" which will be addressed in follow up PRs.
2022-11-10 17:57:10 +01:00
Marcos Casagrande 7bd2c607dd
fix(ext/response): make error, json, redirect enumerable (#16497) 2022-11-10 00:31:14 +01:00
Yoshiya Hinosawa 9edcab524f
fix(ext/flash): revert #16284 and add test case (#16576) 2022-11-09 17:20:05 +09:00
denobot c08fcd96c1
chore: forward v1.27.2 release commit to main (#16572)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2022-11-09 00:27:51 +01:00
Bartek Iwańczuk d0212198b6
refactor(ext/node): remove unwraps (#16559) 2022-11-08 03:16:24 +01:00
Bartek Iwańczuk e7d7da85df
fix(npm): fix CJS resolution with local node_modules dir (#16547)
This commit fixes CJS resolution when there's a local "node_modules/"
directory.

Before this commit relative imports from CJS files where resolved
relative to
root directory of the package instead of relative to referrer file.
2022-11-06 00:58:21 +01:00
Luca Casonato 1410e4adea
fix(ext/http): flush chunk when streaming resource (#16536)
When streaming a resource in ext/http, with compression enabled, we
didn't flush individual chunks. This became very problematic when we
enabled `req.body` from `fetch` for FastStream recently.

This commit now correctly flushes each resource chunk after compression.
2022-11-04 18:59:07 +01:00
denobot 61fbfabe44
chore: forward v1.27.1 release commit to main (#16533)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-11-04 00:40:23 +01:00
David Sherret 77fb26e143
fix(npm): add console global for node environment (#16519)
This global is already isolated to node during type checking.

Closes #16518
2022-11-02 19:08:09 -04:00
Bartek Iwańczuk f5cb26a82f
revert 9ea0ce6198 (#16501)
Closes https://github.com/denoland/deno/issues/16450
2022-11-01 16:06:06 +01:00
Divy Srivastava d76014192d
fix(ext/websocket): make try_send ops infallible (#16454)
Fixes #16450
2022-10-31 12:22:49 +05:30
Kenta Moriuchi 59ac110edd
fix(core): fix APIs not to be affected by Promise.prototype.then modification (#16326) 2022-10-29 18:25:23 +09:00
Filip Skokan ec09134d8a
fix(ext/crypto): fix HMAC jwk import "use" check (#16465) 2022-10-28 19:50:38 +05:30
denobot b0fb8fa9dc
1.27.0 (#16442)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-27 17:13:26 +02:00
Luca Casonato f4f1f4f0b6
feat(ext/net): reusePort for TCP on Linux (#16398) 2022-10-26 19:04:27 +00:00
Marcos Casagrande de580cedd2
refactor(ext/streams): remove fake detached (#16431)
Removed "fake detached" logic since it's no longer needed after
[#16294](https://github.com/denoland/deno/pull/16294) landed
2022-10-26 20:40:26 +02:00
Kitson Kelly a0d10efbb1
chore: improve built-in API documentation (#16158)
Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-26 15:53:48 +02:00
Divy Srivastava 6cd9343e8b
perf(ext/web): optimize transferArrayBuffer (#16294)
Avoid copying enqueued data + misc optimizations to skip webidl
converter.
2022-10-26 18:28:25 +05:30
Bartek Iwańczuk af62e0833d
Revert "Revert "refactor(ext/net): clean up variadic network ops (#16… (#16422)
…392)" (#16417)"

This reverts commit 8e3f825c92.
2022-10-25 22:50:55 +02:00
Bartek Iwańczuk 8e3f825c92
Revert "refactor(ext/net): clean up variadic network ops (#16392)" (#16417)
Should fix https://github.com/denoland/deno_std/issues/2807
2022-10-25 20:32:51 +02:00
David Sherret e203bd9c5a
fix: upgrade swc_ecma_parser to 0.122.19 - deno_ast 0.20 (#16406) 2022-10-25 11:55:57 -04:00
Marcos Casagrande 34fb380ed3
feat(ext/web): use ArrayBuffer.was_detached() (#16307)
This PR adds a way to reliably check if an ArrayBuffer was detached
2022-10-25 14:22:37 +02:00
Marcos Casagrande ac5fcf626a
perf(ext/web): add op_encode_binary_string (#16352)
Add a new op to use in `reader.readAsBinaryString(blob)`.

```
File API binary string: 400b    35.12 µs/iter    (21.93 µs … 3.27 ms)  31.87 µs 131.95 µs 217.63 µs
File API binary string: 4kb     46.49 µs/iter    (29.36 µs … 4.42 ms)   42.5 µs 122.48 µs  155.1 µs
File API binary string: 2.2mb    4.17 ms/iter     (1.75 ms … 8.54 ms)   5.48 ms   7.39 ms   8.54 ms
```

**main**

```
benchmark                          time (avg)             (min … max)       p75       p99      p995
--------------------------------------------------------------------- -----------------------------
File API binary string: 400b    56.17 µs/iter  (43.09 µs … 784.52 µs)   49.6 µs 177.18 µs 241.23 µs
File API binary string: 4kb     277.2 µs/iter   (240.29 µs … 1.84 ms) 269.87 µs 649.79 µs 774.46 µs
File API binary string: 2.2mb  180.03 ms/iter (173.32 ms … 194.35 ms) 182.54 ms 194.35 ms 194.35 ms
```

It can also handle bigger files, when encoding a 200mb file, main
crashes with OOM

```
<--- Last few GCs --->

[132677:0x560504676550]     5012 ms: Scavenge 417.3 (434.6) -> 401.8 (434.6) MB, 0.1 / 0.0 ms  (average mu = 0.824, current mu = 0.825) allocation failure; 
[132677:0x560504676550]     5038 ms: Scavenge 417.3 (434.6) -> 401.8 (434.6) MB, 0.1 / 0.0 ms  (average mu = 0.824, current mu = 0.825) allocation failure; 
[132677:0x560504676550]     5064 ms: Scavenge 417.3 (434.6) -> 401.8 (434.6) MB, 0.1 / 0.0 ms  (average mu = 0.824, current mu = 0.825) allocation failure;
```
2022-10-24 20:27:22 +02:00
Andreu Botella dbcbf53ab5
experiment(ext/web): Don't expose event classes during the bootstrap phase (#16213) 2022-10-24 16:14:17 +02:00
Luca Casonato c061538417
refactor(ext/net): clean up variadic network ops (#16392)
Previously `op_net_listen`, `op_net_accept`, and various other ops in
ext/net where variadic on the transport. This created a lot of code
bloat. This commit updates the code to instead have separate ops for
each transport.
2022-10-24 14:55:39 +02:00