deno
deno copied to clipboard
`Deno.serve` hangs on Windows
With Deno.serve on Windows, the first request is answered successfully, but the second and subsequent requests never reach the server.
const abortController = new AbortController();
const timeoutId = setTimeout(() => {
console.log("60 seconds passed and the server was killed.");
abortController.abort();
}, 60 * 1000);
Deno.unrefTimer(timeoutId);
Deno.serve(() => new Response("hello world"), {
async onListen() {
const res1 = await fetch("http://localhost:9000/1"); // output: "res1: hello world"
console.log("res1: ", await res1.text());
const res2 = await fetch("http://localhost:9000/2"); // this line is not executed on windows
console.log("res2: ", await res2.text());
abortController.abort();
},
signal: abortController.signal,
});
Here are the results of running the test code with GitHub Actions: (It looks like the results are different on Windows and Linux.)
# on linux - It looks like it's working correctly.
res1: hello world
res2: hello world
# on windows - Server does not process second request.
res1: hello world
60 seconds passed and the server was killed.
error: Uncaught (in promise) TypeError: error sending request for url (http://localhost:9000/2): connection error: An existing connection was forcibly closed by the remote host. (os error 100[5](https://github.com/ayame113/deno-flash-test/runs/7964873496?check_suite_focus=true#step:4:6)4)
const res2 = await fetch("http://localhost:9000/2");
^
at async mainFetch (deno:ext/fetch/2[6](https://github.com/ayame113/deno-flash-test/runs/7964873496?check_suite_focus=true#step:4:7)_fetch.js:2[8](https://github.com/ayame113/deno-flash-test/runs/7964873496?check_suite_focus=true#step:4:9)8:14)
at async fetch (deno:ext/fetch/26_fetch.js:505:[9](https://github.com/ayame113/deno-flash-test/runs/7964873496?check_suite_focus=true#step:4:10))
at async onListen (file:///D:/a/deno-flash-test/deno-flash-test/serve.ts:15:18)
Error: Process completed with exit code 1.
Here is the actual log: https://github.com/ayame113/deno-flash-test/actions
If I specify Connection: close in the request header, it works as expected, but if Connection: keep-alive is specified, I think it hangs. Beyond that, I am not sure.😓