summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-02-16 14:27:38 +0100
committerGitHub <noreply@github.com>2022-02-16 14:27:38 +0100
commit7a3ab6b1649847fa7e7f199c37b3502f5c223336 (patch)
treee05648cb3f908262beb8da4979f5bc9a14a4b13f
parent4dff70b4349dbcfc2a46e6886efafafc43d4f69e (diff)
tests: unflake httpServerIncompleteMessage (#13682)
-rw-r--r--cli/tests/unit/http_test.ts38
1 files changed, 13 insertions, 25 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 6a57c2fd1..8ff31b5f7 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -863,37 +863,25 @@ Deno.test(
const ev = await httpConn.nextRequest();
const { respondWith } = ev!;
- const { readable, writable } = new TransformStream<Uint8Array>();
- const writer = writable.getWriter();
-
- async function writeResponse() {
- await delay(50);
- await writer.write(
- new TextEncoder().encode(
- "written to the writable side of a TransformStream",
- ),
- );
- await writer.close();
- }
-
const errors: Error[] = [];
- const writePromise = writeResponse()
- .catch((error: Error) => {
+ const readable = new ReadableStream({
+ async pull(controller) {
+ client.close();
+ await delay(100);
+ controller.enqueue(new TextEncoder().encode(
+ "written to the writable side of a TransformStream",
+ ));
+ controller.close();
+ },
+ cancel(error) {
errors.push(error);
- });
+ },
+ });
const res = new Response(readable);
- const respondPromise = respondWith(res)
- .catch((error: Error) => errors.push(error));
-
- client.close();
-
- await Promise.all([
- writePromise,
- respondPromise,
- ]);
+ await respondWith(res).catch((error: Error) => errors.push(error));
httpConn.close();
listener.close();