mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
tests: unflake httpServerIncompleteMessage (#13682)
This commit is contained in:
parent
4dff70b434
commit
7a3ab6b164
1 changed files with 13 additions and 25 deletions
|
@ -863,37 +863,25 @@ Deno.test(
|
||||||
const ev = await httpConn.nextRequest();
|
const ev = await httpConn.nextRequest();
|
||||||
const { respondWith } = ev!;
|
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 errors: Error[] = [];
|
||||||
|
|
||||||
const writePromise = writeResponse()
|
const readable = new ReadableStream({
|
||||||
.catch((error: Error) => {
|
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);
|
errors.push(error);
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const res = new Response(readable);
|
const res = new Response(readable);
|
||||||
|
|
||||||
const respondPromise = respondWith(res)
|
await respondWith(res).catch((error: Error) => errors.push(error));
|
||||||
.catch((error: Error) => errors.push(error));
|
|
||||||
|
|
||||||
client.close();
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
writePromise,
|
|
||||||
respondPromise,
|
|
||||||
]);
|
|
||||||
|
|
||||||
httpConn.close();
|
httpConn.close();
|
||||||
listener.close();
|
listener.close();
|
||||||
|
|
Loading…
Reference in a new issue