<p dir="auto">Works with a basic example:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="await Deno.serve({ port: 8000 }, () =&gt; new Response());"><pre class="notranslate"><span class="pl-k">await</span> <span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">serve</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">port</span>: <span class="pl-c1">8000</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">=&gt;</span> <span class="pl-k">new</span> <span class="pl-smi">Response</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">It occurs when making a <code class="notranslate">POST</code> request when behind a <code class="notranslate">next-http-proxy-middleware</code> as follows:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import type { NextApiRequest, NextApiResponse } from &quot;next&quot;;
import httpProxyMiddleware from &quot;next-http-proxy-middleware&quot;;

const { API_URL } = process.env;
const handler = (req: NextApiRequest, res: NextApiResponse) =&gt;
  httpProxyMiddleware(req, res, {
    target: API_URL,
    pathRewrite: [{ patternStr: &quot;^/api/&quot;, replaceStr: &quot;/&quot; }],
  });

export default handler;
export const config = {
  api: { externalResolver: true },
};"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-kos">{</span> <span class="pl-smi">NextApiRequest</span><span class="pl-kos">,</span> <span class="pl-smi">NextApiResponse</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"next"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">httpProxyMiddleware</span> <span class="pl-k">from</span> <span class="pl-s">"next-http-proxy-middleware"</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-kos">{</span> <span class="pl-c1">API_URL</span> <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-en">handler</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">req</span>: <span class="pl-smi">NextApiRequest</span><span class="pl-kos">,</span> <span class="pl-s1">res</span>: <span class="pl-smi">NextApiResponse</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span>
  <span class="pl-en">httpProxyMiddleware</span><span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">,</span> <span class="pl-s1">res</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">target</span>: <span class="pl-smi">API_URL</span><span class="pl-kos">,</span>
    <span class="pl-c1">pathRewrite</span>: <span class="pl-kos">[</span><span class="pl-kos">{</span> <span class="pl-c1">patternStr</span>: <span class="pl-s">"^/api/"</span><span class="pl-kos">,</span> <span class="pl-c1">replaceStr</span>: <span class="pl-s">"/"</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-k">export</span> <span class="pl-k">default</span> <span class="pl-s1">handler</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">config</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">api</span>: <span class="pl-kos">{</span> <span class="pl-c1">externalResolver</span>: <span class="pl-c1">true</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">This is enough to reproduce the crash:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -X POST http://localhost:3000/api/v1/abc"><pre class="notranslate"><code class="notranslate">curl -X POST http://localhost:3000/api/v1/abc
</code></pre></div>
<p dir="auto">Here is the backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="===========================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.25.0
Args: [&quot;deno&quot;, &quot;run&quot;, &quot;-A&quot;, &quot;--unstable&quot;, &quot;test.ts&quot;]

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ext/flash/lib.rs:846:41
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll
   4: &lt;extern &quot;C&quot; fn(A0) .&gt; R as v8::support::CFnFrom&lt;F&gt;&gt;::mapping::c_fn
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace."><pre class="notranslate"><code class="notranslate">===========================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.25.0
Args: ["deno", "run", "-A", "--unstable", "test.ts"]

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ext/flash/lib.rs:846:41
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll
   4: &lt;extern "C" fn(A0) .&gt; R as v8::support::CFnFrom&lt;F&gt;&gt;::mapping::c_fn
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
</code></pre></div>
<p dir="auto">Deno Flash server crashes when it serves simple requests. Here is the full content of my <code class="notranslate">src/main.ts</code> file:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Deno.serve({
  handler(request) {
    console.log(request);
    return new Response(&quot;Hello world&quot;);
  },
  hostname: &quot;0.0.0.0&quot;,
  port: 8889,
});"><pre class="notranslate"><span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">serve</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-en">handler</span><span class="pl-kos">(</span><span class="pl-s1">request</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">request</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-smi">Response</span><span class="pl-kos">(</span><span class="pl-s">"Hello world"</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">hostname</span>: <span class="pl-s">"0.0.0.0"</span><span class="pl-kos">,</span>
  <span class="pl-c1">port</span>: <span class="pl-c1">8889</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">This is the request I send to my server from a browser:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fetch(new URL(&quot;/authenticate&quot;, serverUrl), {
      method: &quot;POST&quot;,
      body: JSON.stringify({ accountName, password }),
      headers: { &quot;content-type&quot;: &quot;application/json&quot; },
      mode: &quot;no-cors&quot;,
    });"><pre class="notranslate"><span class="pl-en">fetch</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-smi">URL</span><span class="pl-kos">(</span><span class="pl-s">"/authenticate"</span><span class="pl-kos">,</span> <span class="pl-s1">serverUrl</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
      <span class="pl-c1">method</span>: <span class="pl-s">"POST"</span><span class="pl-kos">,</span>
      <span class="pl-c1">body</span>: <span class="pl-smi">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-kos">{</span> accountName<span class="pl-kos">,</span> password <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
      <span class="pl-c1">headers</span>: <span class="pl-kos">{</span> <span class="pl-s">"content-type"</span>: <span class="pl-s">"application/json"</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">mode</span>: <span class="pl-s">"no-cors"</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">And this is the server console output. Interestingly, the browser receives the response before the server crashes.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="~/projects/server % RUST_BACKTRACE=full deno task start
Warning deno task is unstable and may drastically change in the future
Task start deno run --unstable --allow-net=0.0.0.0:8889 src/main.ts
Listening on http://localhost:8889/
Request {
  bodyUsed: false,
  headers: Headers {
  accept: &quot;*/*&quot;,
  &quot;accept-encoding&quot;: &quot;gzip, deflate, br&quot;,
  &quot;accept-language&quot;: &quot;de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6&quot;,
  &quot;cache-control&quot;: &quot;no-cache&quot;,
  connection: &quot;keep-alive&quot;,
  &quot;content-length&quot;: &quot;34&quot;,
  &quot;content-type&quot;: &quot;text/plain;charset=UTF-8&quot;,
  host: &quot;localhost:8889&quot;,
  origin: &quot;http://localhost:8888&quot;,
  pragma: &quot;no-cache&quot;,
  referer: &quot;http://localhost:8888/&quot;,
  &quot;sec-ch-ua&quot;: '&quot;Google Chrome&quot;;v=&quot;105&quot;, &quot;Not)A;Brand&quot;;v=&quot;8&quot;, &quot;Chromium&quot;;v=&quot;105&quot;',
  &quot;sec-ch-ua-mobile&quot;: &quot;?0&quot;,
  &quot;sec-ch-ua-platform&quot;: '&quot;macOS&quot;',
  &quot;sec-fetch-dest&quot;: &quot;empty&quot;,
  &quot;sec-fetch-mode&quot;: &quot;no-cors&quot;,
  &quot;sec-fetch-site&quot;: &quot;same-site&quot;,
  &quot;user-agent&quot;: &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0....&quot;
},
  method: &quot;POST&quot;,
  redirect: &quot;follow&quot;,
  url: &quot;http://0.0.0.0:8889/authenticate&quot;
}

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.25.1
Args: [&quot;/opt/homebrew/bin/deno&quot;, &quot;run&quot;, &quot;--unstable&quot;, &quot;--allow-net=0.0.0.0:8889&quot;, &quot;src/main.ts&quot;]

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ext/flash/lib.rs:715:41
stack backtrace:
   0:        0x1032c5680 - &lt;std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display&gt;::fmt::h9e1f971b6c458057
   1:        0x102af7da4 - core::fmt::write::hff50bf5ab34a8e88
   2:        0x1032ad300 - std::io::Write::write_fmt::h4b4cac536910ac0e
   3:        0x1032afb5c - std::panicking::default_hook::{{closure}}::h6afa39fd0b64edb8
   4:        0x1032af848 - std::panicking::default_hook::h0ab5dc1706bc4227
   5:        0x102aa8348 - deno::setup_panic_hook::{{closure}}::hef2108c53128687b
   6:        0x1032b046c - std::panicking::rust_panic_with_hook::h4f2beaf7e17e9f84
   7:        0x1032c59bc - std::panicking::begin_panic_handler::{{closure}}::h7bfd5963e591c8e8
   8:        0x1032c5954 - std::sys_common::backtrace::__rust_end_short_backtrace::ha8dd13728d5f8e85
   9:        0x1032affb0 - _rust_begin_unwind
  10:        0x102afa634 - core::panicking::panic_fmt::hd0caa445cceef50a
  11:        0x102afa724 - core::panicking::panic::had6482207444edec
  12:        0x102cab8c8 - &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll::h34fffaa9562104af
  13:        0x102cab158 - &lt;extern &quot;C&quot; fn(A0) .&gt; R as v8::support::CFnFrom&lt;F&gt;&gt;::mapping::c_fn::h97220c381c8504c5"><pre class="notranslate"><code class="notranslate">~/projects/server % RUST_BACKTRACE=full deno task start
Warning deno task is unstable and may drastically change in the future
Task start deno run --unstable --allow-net=0.0.0.0:8889 src/main.ts
Listening on http://localhost:8889/
Request {
  bodyUsed: false,
  headers: Headers {
  accept: "*/*",
  "accept-encoding": "gzip, deflate, br",
  "accept-language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6",
  "cache-control": "no-cache",
  connection: "keep-alive",
  "content-length": "34",
  "content-type": "text/plain;charset=UTF-8",
  host: "localhost:8889",
  origin: "http://localhost:8888",
  pragma: "no-cache",
  referer: "http://localhost:8888/",
  "sec-ch-ua": '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
  "sec-ch-ua-mobile": "?0",
  "sec-ch-ua-platform": '"macOS"',
  "sec-fetch-dest": "empty",
  "sec-fetch-mode": "no-cors",
  "sec-fetch-site": "same-site",
  "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0...."
},
  method: "POST",
  redirect: "follow",
  url: "http://0.0.0.0:8889/authenticate"
}

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.25.1
Args: ["/opt/homebrew/bin/deno", "run", "--unstable", "--allow-net=0.0.0.0:8889", "src/main.ts"]

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ext/flash/lib.rs:715:41
stack backtrace:
   0:        0x1032c5680 - &lt;std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display&gt;::fmt::h9e1f971b6c458057
   1:        0x102af7da4 - core::fmt::write::hff50bf5ab34a8e88
   2:        0x1032ad300 - std::io::Write::write_fmt::h4b4cac536910ac0e
   3:        0x1032afb5c - std::panicking::default_hook::{{closure}}::h6afa39fd0b64edb8
   4:        0x1032af848 - std::panicking::default_hook::h0ab5dc1706bc4227
   5:        0x102aa8348 - deno::setup_panic_hook::{{closure}}::hef2108c53128687b
   6:        0x1032b046c - std::panicking::rust_panic_with_hook::h4f2beaf7e17e9f84
   7:        0x1032c59bc - std::panicking::begin_panic_handler::{{closure}}::h7bfd5963e591c8e8
   8:        0x1032c5954 - std::sys_common::backtrace::__rust_end_short_backtrace::ha8dd13728d5f8e85
   9:        0x1032affb0 - _rust_begin_unwind
  10:        0x102afa634 - core::panicking::panic_fmt::hd0caa445cceef50a
  11:        0x102afa724 - core::panicking::panic::had6482207444edec
  12:        0x102cab8c8 - &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll::h34fffaa9562104af
  13:        0x102cab158 - &lt;extern "C" fn(A0) .&gt; R as v8::support::CFnFrom&lt;F&gt;&gt;::mapping::c_fn::h97220c381c8504c5
</code></pre></div>