summaryrefslogtreecommitdiff
path: root/cli/js/net_test.ts
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2019-11-09 19:40:22 +0000
committerRy Dahl <ry@tinyclouds.org>2019-11-09 14:40:22 -0500
commitd586f119fa588a590a4ba2b74c8c210de710e3e7 (patch)
tree0a6a249c46c70c8326221ad79fb4e7fc739dc488 /cli/js/net_test.ts
parent9889a28008eb9da1793bb9987bafe0b4952dd90a (diff)
net: Check for closing status when iterating Listener (#3309)
std/http/server.ts: Use listener.next() instead of listener.accept()
Diffstat (limited to 'cli/js/net_test.ts')
-rw-r--r--cli/js/net_test.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/js/net_test.ts b/cli/js/net_test.ts
index 33f4f7d07..dc7451434 100644
--- a/cli/js/net_test.ts
+++ b/cli/js/net_test.ts
@@ -77,6 +77,18 @@ testPerm({ net: true }, async function netDialListen(): Promise<void> {
conn.close();
});
+testPerm({ net: true }, async function netListenCloseWhileIterating(): Promise<
+ void
+> {
+ const listener = Deno.listen({ port: 8000 });
+ const nextWhileClosing = listener[Symbol.asyncIterator]().next();
+ listener.close();
+ assertEquals(await nextWhileClosing, { value: undefined, done: true });
+
+ const nextAfterClosing = listener[Symbol.asyncIterator]().next();
+ assertEquals(await nextAfterClosing, { value: undefined, done: true });
+});
+
/* TODO(ry) Re-enable this test.
testPerm({ net: true }, async function netListenAsyncIterator(): Promise<void> {
const listener = Deno.listen(":4500");