1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00
denoland-deno/cli
Matt Mastracci 576d0db372
fix(ext/http): ensure request body resource lives as long as response is alive (#20206)
Deno.serve's fast streaming implementation was not keeping the request
body resource ID alive. We were taking the `Rc<Resource>` from the
resource table during the response, so a hairpin duplex response that
fed back the request body would work.

However, if any JS code attempted to read from the request body (which
requires the resource ID to be valid), the response would fail with a
difficult-to-diagnose "EOF" error.

This was affecting more complex duplex uses of `Deno.fetch` (though as
far as I can tell was unreported).

Simple test:

```ts
        const reader = request.body.getReader();
        return new Response(
          new ReadableStream({
            async pull(controller) {
              const { done, value } = await reader.read();
              if (done) {
                controller.close();
              } else {
                controller.enqueue(value);
              }
            },
          }),
```

And then attempt to use the stream in duplex mode:

```ts

async function testDuplex(
  reader: ReadableStreamDefaultReader<Uint8Array>,
  writable: WritableStreamDefaultWriter<Uint8Array>,
) {
  await writable.write(new Uint8Array([1]));
  const chunk1 = await reader.read();
  assert(!chunk1.done);
  assertEquals(chunk1.value, new Uint8Array([1]));
  await writable.write(new Uint8Array([2]));
  const chunk2 = await reader.read();
  assert(!chunk2.done);
  assertEquals(chunk2.value, new Uint8Array([2]));
  await writable.close();
  const chunk3 = await reader.read();
  assert(chunk3.done);
}
```

In older versions of Deno, this would just lock up. I believe after
23ff0e722e, it started throwing a more
explicit error:

```
httpServerStreamDuplexJavascript => ./cli/tests/unit/serve_test.ts:1339:6
error: TypeError: request or response body error: error reading a body from connection: Connection reset by peer (os error 54)
    at async Object.pull (ext:deno_web/06_streams.js:810:27)
```
2023-08-21 01:35:26 +00:00
..
args fix(cli) error gracefully when script arg is not present and --v8-flags is present in deno run (#20145) 2023-08-13 04:04:17 +02:00
bench chore: remove third_party submodule (#20201) 2023-08-19 09:56:12 +05:30
cache refactor: use deno_cache_dir crate (#20092) 2023-08-08 14:23:02 +00:00
js fix(test): handle ASCII escape chars in test name (#20081) 2023-08-10 01:40:34 +02:00
lsp fix(unstable): disable importing from the vendor directory (#20067) 2023-08-17 16:14:22 +00:00
napi chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
npm feat(ext/node): eagerly bootstrap node (#20153) 2023-08-16 04:36:36 +09:00
ops build: allow disabling snapshots for dev (#20048) 2023-08-06 01:47:15 +02:00
schemas feat(unstable): rename deno_modules to vendor (#20065) 2023-08-06 21:56:56 -04:00
standalone feat(ext/node): eagerly bootstrap node (#20153) 2023-08-16 04:36:36 +09:00
tests fix(ext/http): ensure request body resource lives as long as response is alive (#20206) 2023-08-21 01:35:26 +00:00
tools fix(test): JUnit reporter includes file, line and column attributes (#20174) 2023-08-17 23:41:29 +02:00
tsc feat(ext/kv): key expiration (#20091) 2023-08-18 17:34:16 +08:00
util feat(unstable): rename deno_modules to vendor (#20065) 2023-08-06 21:56:56 -04:00
auth_tokens.rs chore: upgrade to Rust 1.67 (#17548) 2023-01-27 10:43:16 -05:00
build.rs build: remove redundant rerun-if-changed for compiler snapshot (#20094) 2023-08-08 09:21:54 +02:00
Cargo.toml fix(cli): handle missing now field in cache (#20192) 2023-08-17 15:25:00 +00:00
deno.ico
deno_std.rs chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
emit.rs refactor(lsp): move config file related code to config.rs (#19790) 2023-07-10 21:45:09 +00:00
errors.rs feat: TypeScript 5.0.2 (except decorators) (#18294) 2023-03-21 15:46:40 +00:00
factory.rs fix(unstable): disable importing from the vendor directory (#20067) 2023-08-17 16:14:22 +00:00
file_fetcher.rs refactor: use deno_cache_dir crate (#20092) 2023-08-08 14:23:02 +00:00
graph_util.rs feat(unstable): optional deno_modules directory (#19977) 2023-08-02 00:49:09 +00:00
http_util.rs feat(unstable): add more options to Deno.createHttpClient (#17385) 2023-05-21 03:43:54 +02:00
js.rs build: allow disabling snapshots for dev (#20048) 2023-08-06 01:47:15 +02:00
main.rs fix(lint): allow to use --rules with --rules-tags (#19754) 2023-07-25 17:24:06 -04:00
module_loader.rs chore: rename some helpers on the Fs trait (#20097) 2023-08-08 16:28:18 -04:00
node.rs chore: rename some helpers on the Fs trait (#20097) 2023-08-08 16:28:18 -04:00
README.md docs(cli): do not need gen doc for cli (#17260) 2023-01-04 13:19:58 +01:00
resolver.rs fix(unstable): disable importing from the vendor directory (#20067) 2023-08-17 16:14:22 +00:00
version.rs refactor: make version and user_agent &'static str (#18400) 2023-03-23 23:27:58 +01:00
worker.rs feat(ext/node): eagerly bootstrap node (#20153) 2023-08-16 04:36:36 +09:00

Deno CLI Crate

crates

This provides the actual deno executable and the user-facing APIs.

The deno crate uses the deno_core to provide the executable.