denoland/denobyexample

Error in ReadableStream in http-requests.ts

dannyfritz opened this issue · 0 comments

$ deno run --allow-net https://examples.deno.land/http-requests.ts
... bunch of other output ...
error: Uncaught (in promise) TypeError: Failed to fetch: request body stream errored
resp = await fetch("https://example.com", {
       ^
    at mainFetch (ext:deno_fetch/26_fetch.js:283:13)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async fetch (ext:deno_fetch/26_fetch.js:501:7)
    at async https://examples.deno.land/http-requests.ts:52:8
Caused by: TypeError: Item in request body ReadableStream is not a Uint8Array
    at ext:deno_fetch/26_fetch.js:245:25
    at eventLoopTick (ext:core/01_core.js:183:11)

Minimal example:

const bodyStream = new ReadableStream({
  start(controller) {
    controller.enqueue("Hello, World!");
    controller.close();
  },
});
resp = await fetch("https://example.com", {
  method: "POST",
  body: bodyStream,
});
~/Dev/hobby/learn-deno 0.11s
❯ deno -V
deno 1.36.4