1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

792 commits

Author SHA1 Message Date
denobot
b9527f5020
chore: forward v1.29.1 release commit to main (#17067)
Co-authored-by: dsherret <dsherret@users.noreply.github.com>
2022-12-15 13:30:55 -05:00
Bartek Iwańczuk
585ec1218f
Revert "feat(ops): Fast zero copy string arguments (#16777)" (#17063)
This reverts commit 9b2b8df927.

Closes https://github.com/dsherret/ts-morph/issues/1372
Closes https://github.com/denoland/deno/issues/16979
2022-12-15 15:26:10 +00:00
denobot
0d4e4af7ac
1.29.0 (#17052)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-12-15 00:22:54 +01:00
Bartek Iwańczuk
f9db129bdf
feat: Stabilize Deno.TcpConn.setNoDelay() and Deno.TcpConn.setKeepAlive() (#17003)
This commit stabilizes following APIs:
- `Deno.TcpConn.setNoDelay()`
- `Deno.TcpConn.setKeepAlive()`
2022-12-14 00:54:11 +01:00
Divy Srivastava
ac4b5de656
feat(napi): improve napi coverage (#16198) 2022-12-13 19:56:53 +05:30
Leo Kettmeir
76a9df1ed8
docs: use example & default tags (#17032) 2022-12-13 14:14:41 +01:00
Divy Srivastava
a2db70a8d0
refactor(ext/ffi): split into multiple parts (#16950)
- [x] `dlfcn.rs` - `dlopen()`-related code.
- [x] `turbocall.rs` - Call trampoline JIT compiler. 
- [x] `repr.rs` - Pointer representation. Home of the UnsafePointerView
ops.
- [x] `symbol.rs` - Function symbol related code.
- [x] `callback.rs` - Home of `Deno.UnsafeCallback` ops.
- [x] `ir.rs` - Intermediate representation for values. Home of the
`NativeValue` type.
- [x] `call.rs` - Generic call ops. Home to everything related to
calling FFI symbols.
- [x] `static.rs` - static symbol support

I find easier to work with this setup, I eventually want to expand
TurboCall to unroll type conversion loop in generic calls, generate code
for individual symbols (lazy function pointers), etc.
2022-12-12 14:14:20 +00:00
David Sherret
dac30af151
feat(fmt): improve width calculation (#16982)
Formats code according to Unicode Standard Annex #11 rules
(https://crates.io/crates/unicode-width).

This aligns `deno fmt` more with prettier.
2022-12-07 17:32:24 -05:00
Divy Srivastava
791e623c32
fix(ext/websocket): Reland make try_send ops infallible (#16968)
Reverts denoland/deno#16743

This fixes the server hangs we were seeing in benchy. cc @billywhizz
2022-12-07 18:04:02 +05:30
Luca Casonato
923370f18f
fix(ext/fetch): new Request should soft clone (#16869)
Previously the inner request object of the original and the new request
were the same, causing the requests to be entangled and mutable changes
to one to be visible to the other. This fixes that.
2022-12-06 09:39:04 +01:00
Bartek Iwańczuk
3863aaf8ae
refactor: remove references to Deno.core in bootstrap code (#16937)
Prerequisite for https://github.com/denoland/deno/pull/16881
2022-12-05 17:11:57 +01:00
Divy Srivastava
55595ca1b7
fix(ops): disallow auto-borrowing OpState across potential await point (#16952)
Fixes https://github.com/denoland/deno/issues/16934

Example compiler error:
```
error: mutable opstate is not supported in async ops
   --> core/ops_builtin.rs:122:1
    |
122 | #[op]
    | ^^^^^
    |
    = note: this error originates in the attribute macro `op` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2022-12-05 21:40:22 +05:30
Divy Srivastava
9b2b8df927
feat(ops): Fast zero copy string arguments (#16777)
Uses SeqOneByteString optimization to do zero-copy `&str` arguments in
fast calls.

- [x] Depends on https://github.com/denoland/rusty_v8/pull/1129
- [x] Depends on
https://chromium-review.googlesource.com/c/v8/v8/+/4036884
- [x] Disable in async ops
- [x] Make it work with owned `String` with an extra alloc in fast path.
- [x] Support `Cow<'_, str>`. Owned for slow case, Borrowed for fast
case

```rust
#[op]
fn op_string_len(s: &str) -> u32 { 
  str.len() as u32 
}
```
2022-12-02 05:29:15 +00:00
Divy Srivastava
824cb485c5
perf(ext/websocket): skip Events constructor checks (#16365)
WebSocket internal events can bypass Event's webidl checks and
`ReflectDefineProperty` on the object value. Note, this intentionally
makes websocket events `isTrusted` configurable (not spec-compliant)
which hurts performance a lot.

Before:
```
Msg/sec: 167627.750000
Msg/sec: 168239.250000
Msg/sec: 169690.000000
```

After:
```
Msg/sec: 191065.500000
Msg/sec: 194745.250000
Msg/sec: 194746.000000
```
2022-12-01 20:05:32 +05:30
denobot
98d062e3dc
chore: forward v1.28.3 release commit to main (#16884)
Co-authored-by: kt3k <kt3k@users.noreply.github.com>
2022-12-01 22:46:27 +09:00
David Sherret
b1e29d1bd0
fix(npm): improve package.json exports support for types (#16880) 2022-11-30 23:07:32 +00:00
Bartek Iwańczuk
381932ce1e
chore: upgrade rusty_v8 to 0.58.0 (#16879) 2022-11-30 22:20:18 +00:00
ud2
972048ce36
fix(ext/web): fix typings for readable stream readers (#16191)
* Introduces `ReadableStreamDefaultReadResult` and modifies
`ReadableStreamDefaultReader.read` to return this type (closes #15269).
* Adds the missing `ReadableStreamBYOBReader` constructor.
* Removes the nonexistent `ReadableStreamReader` class.
2022-11-30 16:24:13 +01:00
Yoshiya Hinosawa
e4fe5ee72a
fix(ext/node): allow absolute path in createRequire (#16853)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-11-29 14:13:14 +09:00
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
Marcos Casagrande
f38666f5a3
fix(ext/fetch): fix size_hint on response body resource (#16254) 2022-10-24 13:26:41 +02:00
Marcos Casagrande
b7d86b4bed
perf(ext/streams): fast path when consuming body of tee'd stream (#16329)
Add a fast path for consuming the body of cloned `Request`/`Response`,
which is very common specially when using `cache` API.
2022-10-24 13:13:20 +02:00
Gianluca Oldani
873a5ce2ed
feat(ext/net): add reuseAddress option for UDP (#13849)
This commit adds a `reuseAddress` option for UDP sockets. When this
option is enabled, one can listen on an address even though it is
already being listened on from a different process or thread. The new
socket will steal the address from the existing socket.

On Windows and Linux this uses the `SO_REUSEADDR` option, while on other
Unixes this is done with `SO_REUSEPORT`.

This behavior aligns with what libuv does.

TCP sockets still unconditionally set the `SO_REUSEADDR` flag - this
behavior matches Node.js and Go. This PR does not change this behaviour.

Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-10-24 09:05:07 +00:00
Luca Casonato
38213f1142
fix(ext/net): don't remove sockets on unix listen (#16394)
When listening on a UNIX socket path, Deno currently tries to unlink
this path prior to actually listening. The implementation of this
behaviour is VERY racy, involves 2 additional syscalls, and does not
match the behaviour of any other runtime (Node.js, Go, Rust, etc).

This commit removes this behaviour. If a user wants to listen on an
existing socket, they must now unlink the file themselves prior to
listening.

This change in behaviour only impacts --unstable APIs, so it is not
a breaking change.
2022-10-24 00:45:45 +02:00
Marcos Casagrande
0e1167d12d
perf(ext/web/encoding): avoid copy in decode (#16364) 2022-10-23 21:09:15 +02:00
David Sherret
bcfe279fba
feat(unstable/npm): initial type checking of npm specifiers (#16332) 2022-10-21 15:20:18 +00:00
Divy Srivastava
0f27b84a5c
chore(core): remove core.opSync (#16379)
This patch removes the last uses of `core.opSync` from Deno.

The new and JIT-friendly way to call sync ops is `core.ops.op_name()`.
2022-10-21 19:35:23 +05:30
Bartek Iwańczuk
869acee8fb
chore: upgrade rusty_v8 to 0.54.0 (#16368)
<!--
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-10-20 21:01:49 +02:00
Divy Srivastava
bfc1fb8d68
perf(serde_v8): serde_v8::StringOrBuffer return JS ArrayBuffer instead of Uint8Array (#16360)
Towards #16315
2022-10-20 16:03:57 +05:30
Aapo Alasuutari
e2be70b035
feat(ext/ffi): Make op_ffi_ptr_of fast (#16297)
Makes `op_ffi_ptr_of` fast. One of the tests changed from printing
`false` to `true` as the fast `&[u8]` slice path creates the slice with
a null pointer. Thus the `op_ffi_ptr_of` will now return a null pointer
value whereas previously it returned a dangling pointer value.
2022-10-20 09:37:37 +05:30
Aapo Alasuutari
722ea20e86
perf(ext/ffi): Fast UnsafePointerView read functions (#16351)
This PR makes pointer read methods of `Deno.UnsafePointerView` Fast API
compliant, with the exception of `getCString` which cannot be made fast
with current V8 Fast API.
2022-10-20 09:35:56 +05:30
Divy Srivastava
e3a3095481
perf(ext/websocket): optimize op_ws_next_event (#16325)
Towards https://github.com/denoland/deno/issues/16315
2022-10-19 17:20:41 +05:30
Divy Srivastava
743fcc0668
perf(ext/flash): optimize path response streams (#16284)
Regression caused by https://github.com/denoland/deno/pull/15591
2022-10-19 16:41:47 +05:30
Divy Srivastava
36307c45e9
perf(ext/websocket): optimize socket.send (#16320)
Towards #16315
2022-10-19 16:23:13 +05:30
Yusuke Tanaka
44a89dd6dc
fix(ext/net): return an error from startTls and serveHttp if the original connection is captured elsewhere (#16242)
This commit removes the calls to `expect()` on `std::rc::Rc`, which caused
Deno to panic under certain situations. We now return an error if `Rc`
is referenced by other variables.

Fixes #9360
Fixes #13345
Fixes #13926
Fixes #16241

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-18 11:28:27 +09:00
Bartek Iwańczuk
204c46dcc1
chore: forward v1.26.2 to main (#16331)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>

<!--
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.
-->

Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2022-10-17 23:11:16 +02:00
Marcos Casagrande
d0e78ca5c6
fix(ext/fetch): set accept-encoding: identity if range header is present (#16197)
https://fetch.spec.whatwg.org/#http-network-or-cache-fetch

> If httpRequest’s header list contains `Range`, then append
(`Accept-Encoding`, `identity`)
> to httpRequest’s header list.
> 
> This avoids a failure when handling content codings with a part of an
encoded response.
> Additionally, many servers mistakenly ignore `Range` headers if a
non-identity encoding is accepted.
2022-10-17 15:39:41 +02:00
Divy Srivastava
4c9dd33e27
perf(ext/web): optimize timer cancellation (#16316)
Towards #16315 

It created a bunch of Error objects and rejected the promise. This patch
changes `op_sleep` to resolve with `true` if it was cancelled.
2022-10-17 16:59:16 +05:30
Divy Srivastava
0dc2f02dfa
perf(ext/web): optimize op_cancel_handle (#16318)
Towards #16315
2022-10-17 16:12:05 +05:30
Marcos Casagrande
5252ff5dbd
fix(ext/cache): illegal constructor (#16205) 2022-10-16 23:03:17 +05:30
Bartek Iwańczuk
40009ebc94
fix(npm): disable loading native module for "fsevents" package (#16273)
Currently causes a hang in Vite, disable this one specific package
as remaining tests for NAPI in various modules work fine.
2022-10-16 15:03:38 +02:00
David Sherret
4ea4d3ad60
chore: fix windows-only clippy errors (#16289) 2022-10-15 13:56:54 +00:00
Aapo Alasuutari
75acec0aea
fix(ext/ffi): Fix UnsafeCallback ref'ing making Deno enter a live-loop (#16216)
Fixes #15136

Currently `UnsafeCallback` class' `ref()` and `unref()` methods rely on
the `event_loop_middleware` implementation in core. If even a single
`UnsafeCallback` is ref'ed, then the FFI event loop middleware will
always return `true` to signify that there may still be more work for
the event loop to do.

The middleware handling in core does not wait a moment to check again,
but will instead synchronously directly re-poll the event loop and
middlewares for more work. This becomes a live-loop.

This PR introduces a `Future` implementation for the `CallbackInfo`
struct that acts as the intermediary data storage between an
`UnsafeCallback` and the `libffi` C callback. Ref'ing a callback now
means calling an async op that binds to the `CallbackInfo` Future and
only resolves once the callback is unref'ed. The `libffi` C callback
will call the waker of this Future when it fires to make sure that the
main thread wakes up to receive the callback.
2022-10-15 19:19:46 +05:30
Aapo Alasuutari
9c7a5c0c61
fix(ext/websocket): panic on no next ws message from an already closed stream (#16004) 2022-10-15 11:08:09 +02:00
Filip Skokan
225d516466
fix(ext/crypto): correct HMAC get key length op (#16201)
fixes #16180

`HMAC`'s `get key length` `op` uses the hash function's block size, not
output size.

refs
https://github.com/cloudflare/workerd/issues/68#issuecomment-1271189657
2022-10-15 10:53:35 +05:30
Marcos Casagrande
e6e2898190
fix(ext/web/streams): enqueue to second branch before closing (#16269)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-10-14 09:51:39 +00:00
Marcos Casagrande
0d6dbc08be
fix(ext/fetch): throw TypeError on non-Uint8Array chunk (#16262) 2022-10-14 11:38:17 +02:00
Marcos Casagrande
50c7b89369
fix(ext/web/streams): resolve cancelPromise in ReadableStreamTee (#16266) 2022-10-14 11:29:01 +02:00
Aapo Alasuutari
17271532d4
fix(ext/ffi): Invalid 'function' return type check logic, remove U32x2 as unnecessary (#16259)
The return type checking for `"function"` type FFI values was incorrect
and presumed that functions were still being registered as objects
containing a "function" key.

While here, I also removed the whole return type checking logic as it
was needed for optionally creating BigInts on return when needed, but
serde_v8 does this automatically now (I think).
2022-10-13 17:36:52 +05:30
Xiao Xiao
ba3d0da6ab
chore(ext/web): fix typo (#16248)
implictly -> implicitly
assiging -> assigning
2022-10-12 07:47:15 +00:00
Marcos Casagrande
d47b17d37d
fix(ext/fetch): throw TypeError on read failure (#16219) 2022-10-12 09:23:33 +02:00