refactor(op_crate/fetch): align streams to spec (#9103)

Fixes #8814
This commit is contained in:
Kitson Kelly 2021-01-15 08:57:19 +11:00 committed by GitHub
parent 2d1208556a
commit b8303c7812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 3225 additions and 3678 deletions

View file

@ -1047,9 +1047,13 @@ unitTest(
const buf = bufferServer(addr);
const stream = new TransformStream();
const writer = stream.writable.getWriter();
await writer.write(new TextEncoder().encode("hello "));
await writer.write(new TextEncoder().encode("world"));
await writer.close();
// transformer writes don't resolve until they are read, so awaiting these
// will cause the transformer to hang, as the suspend the transformer, it
// is also illogical to await for the reads, as that is the whole point of
// streams is to have a "queue" which gets drained...
writer.write(new TextEncoder().encode("hello "));
writer.write(new TextEncoder().encode("world"));
writer.close();
const response = await fetch(`http://${addr}/blah`, {
method: "POST",
headers: [