mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
fix(std/http): Properly await ops in a server test (#4436)
This commit is contained in:
parent
b7e6a31a42
commit
35f6e2e45d
1 changed files with 3 additions and 4 deletions
|
@ -462,12 +462,12 @@ test({
|
|||
async fn(): Promise<void> {
|
||||
async function iteratorReq(server: Server): Promise<void> {
|
||||
for await (const req of server) {
|
||||
req.respond({ body: new TextEncoder().encode(req.url) });
|
||||
await req.respond({ body: new TextEncoder().encode(req.url) });
|
||||
}
|
||||
}
|
||||
|
||||
const server = serve(":8123");
|
||||
iteratorReq(server);
|
||||
const p = iteratorReq(server);
|
||||
const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 });
|
||||
await Deno.writeAll(
|
||||
conn,
|
||||
|
@ -479,8 +479,7 @@ test({
|
|||
const resStr = new TextDecoder().decode(res.subarray(0, nread));
|
||||
assertStrContains(resStr, "/hello");
|
||||
server.close();
|
||||
// Defer to allow async ops to resolve after server has been closed.
|
||||
await delay(0);
|
||||
await p;
|
||||
// Client connection should still be open, verify that
|
||||
// it's visible in resource table.
|
||||
const resources = Deno.resources();
|
||||
|
|
Loading…
Reference in a new issue