From da10c9c8d1f7bf6ada71bb70f5f331ed830e5b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 26 Aug 2022 05:12:11 +0200 Subject: fix(ext/flash): panic on AddrInUse (#15607) --- cli/tests/unit/flash_test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts index 07be6dfcc..fef45beb9 100644 --- a/cli/tests/unit/flash_test.ts +++ b/cli/tests/unit/flash_test.ts @@ -57,6 +57,35 @@ Deno.test(async function httpServerCanResolveHostnames() { await server; }); +Deno.test(async function httpServerRejectsOnAddrInUse() { + const ac = new AbortController(); + const listeningPromise = deferred(); + + const server = Deno.serve({ + handler: (_req) => new Response("ok"), + hostname: "localhost", + port: 4501, + signal: ac.signal, + onListen: onListen(listeningPromise), + onError: createOnErrorCb(ac), + }); + + assertRejects( + () => + Deno.serve({ + handler: (_req) => new Response("ok"), + hostname: "localhost", + port: 4501, + signal: ac.signal, + onListen: onListen(listeningPromise), + onError: createOnErrorCb(ac), + }), + Deno.errors.AddrInUse, + ); + ac.abort(); + await server; +}); + Deno.test({ permissions: { net: true } }, async function httpServerBasic() { const ac = new AbortController(); const promise = deferred(); -- cgit v1.2.3