<p dir="auto">I've set up a rudimentary server on AWS EC2 (Debian Linux) running Deno 1.9.1 with an SSL certificate from Let's Encrypt. It simply serves a static HTML file when dealing with a GET request for "/", and returns a 404 for all other requests.</p>
<p dir="auto">It works fine for a while, and then starts hanging on all requests after a seemingly random amount of time. The code is the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { listenAndServeTLS } from &quot;https://deno.land/std/http/server.ts&quot;;

const options = {
  hostname: &quot;www.example.org&quot;,
  port: 443,
  certFile: &quot;./keys/cert.pem&quot;,
  keyFile: &quot;./keys/key.pem&quot;,
};

const index = await Deno.readTextFile(&quot;./static/index.html&quot;);
const notFound = await Deno.readTextFile(&quot;./static/notfound.html&quot;);

listenAndServeTLS(options, (req) =&gt;{ 
  let statusCode, content;
  if (req.url === &quot;/&quot;) {
    statusCode = 200;
    content = index;
  } else {
    statusCode = 404;
    content = notFound;
  }

  console.log(`${statusCode} ${req.method} ${req.url}`);
  req.respond({
    status: statusCode,
    headers: new Headers({
      &quot;content-type&quot;: &quot;text/html&quot;,
    }),
    body: content,
  });
});"><pre class="notranslate"><code class="notranslate">import { listenAndServeTLS } from "https://deno.land/std/http/server.ts";

const options = {
  hostname: "www.example.org",
  port: 443,
  certFile: "./keys/cert.pem",
  keyFile: "./keys/key.pem",
};

const index = await Deno.readTextFile("./static/index.html");
const notFound = await Deno.readTextFile("./static/notfound.html");

listenAndServeTLS(options, (req) =&gt;{ 
  let statusCode, content;
  if (req.url === "/") {
    statusCode = 200;
    content = index;
  } else {
    statusCode = 404;
    content = notFound;
  }

  console.log(`${statusCode} ${req.method} ${req.url}`);
  req.respond({
    status: statusCode,
    headers: new Headers({
      "content-type": "text/html",
    }),
    body: content,
  });
});
</code></pre></div>
<p dir="auto">After the server starts hanging, curl outputs the following (and hangs as well):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to www.example.org (127.0.0.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* Operation timed out after 300401 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 300401 milliseconds with 0 out of 0 bytes received"><pre class="notranslate"><code class="notranslate">*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to www.example.org (127.0.0.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* Operation timed out after 300401 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 300401 milliseconds with 0 out of 0 bytes received
</code></pre></div>
<p dir="auto">Am I doing something wrong? I'm starting a big project based on Deno and this is blocking.</p>
<p dir="auto">Okay, this is a very strange issue, so I'm not very sure where to put this. Let's say I have this Deno HTTPS server:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { serveTLS } from &quot;https://deno.land/std@0.89.0/http/server.ts&quot;;

const server = serveTLS({
  port: 443,
  hostname: &quot;0.0.0.0&quot;,
  certFile: &quot;cert/fullchain.pem&quot;,
  keyFile: &quot;cert/key.pem&quot;,
});

for await (const req of server) {
  (async () =&gt; {
    const file = await Deno.open(&quot;image.png&quot;);
    await req.respond({
      headers: new Headers({
        &quot;Content-Type&quot;: &quot;image/png&quot;,
      }),
      body: file,
    });
    await req.done;
    file.close();
  })();
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">serveTLS</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://deno.land/std@0.89.0/http/server.ts"</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">server</span> <span class="pl-c1">=</span> <span class="pl-en">serveTLS</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">port</span>: <span class="pl-c1">443</span><span class="pl-kos">,</span>
  <span class="pl-c1">hostname</span>: <span class="pl-s">"0.0.0.0"</span><span class="pl-kos">,</span>
  <span class="pl-c1">certFile</span>: <span class="pl-s">"cert/fullchain.pem"</span><span class="pl-kos">,</span>
  <span class="pl-c1">keyFile</span>: <span class="pl-s">"cert/key.pem"</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">for</span> <span class="pl-k">await</span> <span class="pl-kos">(</span><span class="pl-k">const</span> <span class="pl-s1">req</span> <span class="pl-k">of</span> <span class="pl-s1">server</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-kos">(</span><span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">file</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">open</span><span class="pl-kos">(</span><span class="pl-s">"image.png"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">respond</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
      <span class="pl-c1">headers</span>: <span class="pl-k">new</span> <span class="pl-smi">Headers</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
        <span class="pl-s">"Content-Type"</span>: <span class="pl-s">"image/png"</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
      <span class="pl-c1">body</span>: <span class="pl-s1">file</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">done</span><span class="pl-kos">;</span>
    <span class="pl-s1">file</span><span class="pl-kos">.</span><span class="pl-en">close</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Using the following image file:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/11262022/110100122-58a03380-7da2-11eb-86ac-1693f29cc460.png"><img src="https://user-images.githubusercontent.com/11262022/110100122-58a03380-7da2-11eb-86ac-1693f29cc460.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">I'm on Windows 10.0.19042.804.</p>
<p dir="auto">(Edit) Deno version:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="deno 1.8.0 (release, x86_64-pc-windows-msvc)
v8 9.0.257.3
typescript 4.2.2"><pre class="notranslate"><code class="notranslate">deno 1.8.0 (release, x86_64-pc-windows-msvc)
v8 9.0.257.3
typescript 4.2.2
</code></pre></div>
<p dir="auto">On Windows, when I request this server from a browser or curl, it seems to only load the first 64KiB and then hang the request:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/11262022/110100340-94d39400-7da2-11eb-8c90-f089c9304e69.png"><img src="https://user-images.githubusercontent.com/11262022/110100340-94d39400-7da2-11eb-8c90-f089c9304e69.png" alt="2021-03-05_11-04-11" style="max-width: 100%;"></a></p>
<p dir="auto">If I run the same program in Deno in WSL (1) it works completely fine.</p>
<p dir="auto">Also if I try to set the file to a 2.5MB JS file, it loads the entire file fine on Windows too, and doesn't hang the request, so there seems to be something that ONLY fails for Windows + binary files going on here.</p>
<p dir="auto">Am I doing something wrong in my code?</p>