title: nodejs http server: how to end a request when got error?
body: <p>In app.js:</p>
  
  <pre><code>const server = http.createServer(function (req, res) {
      require('./ctl/index.js')(req,res)
  });
  </code></pre>
  
  <p>In ctl/index.js:</p>
  
  <pre><code>module.exports =  async (req,res) =&gt; {
      func_not_exists(); // for testing purpose
      res.end("ok");
  }
  </code></pre>
  
  <p>After I start the server using <code>node app.js</code>, open the url from a web browser, I can get <code>is not a function</code> msg from log, but the request process is not end (the web browser icon keep spin). How can I end the user request immediately after got error?  </p>
  
  <p>(I'm not using Express.js, but pure http module. I don't want to end whole process using process.exit(), just want to end the current user request.)</p>