diff options
author | Yazan AbdAl-Rahman <yazan.abdalrahman@exalt.ps> | 2024-07-09 14:44:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-09 13:44:12 +0200 |
commit | c11e2c74e874af29b6ade13ee4ab51a72853d726 (patch) | |
tree | 27f43740c2331a437f72c8c8cbfb70085a2b32d9 /tests | |
parent | 77c5a336adde9cdf7c0ce35dd24f83f1a887570e (diff) |
fix(net): handle panic on Windows for Unix socket usage in Deno.serve() (#24423)
This PR addresses the issue where Deno.serve() panics on Windows when
trying to use a Unix socket.
Fixes #21967
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/serve_test.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/serve_test.ts b/tests/unit/serve_test.ts index 363667066..4239221be 100644 --- a/tests/unit/serve_test.ts +++ b/tests/unit/serve_test.ts @@ -4034,3 +4034,28 @@ Deno.test( await server.finished; }, ); + +Deno.test({ + name: "HTTP Server test (error on non-unix platform)", + ignore: Deno.build.os !== "windows", +}, async () => { + await assertRejects( + async () => { + const ac = new AbortController(); + const server = Deno.serve({ + path: "path/to/socket", + handler: (_req) => new Response("Hello, world"), + signal: ac.signal, + onListen({ path: _path }) { + console.log(`Server started at ${_path}`); + }, + }); + server.finished.then(() => console.log("Server closed")); + console.log("Closing server..."); + ac.abort(); + await new Promise((resolve) => setTimeout(resolve, 100)); // Example of awaiting something + }, + Error, + 'Operation `"op_net_listen_unix"` not supported on non-unix platforms.', + ); +}); |