Repository: deno
Issue: ext/node(http): "close" event not emitted on a response when client terminates
Labels: bug,node compat

Example:

```js
import http from 'node:http';
import net from 'node:net';
import assert from 'node:assert';

// Create an HTTP server
const server = http.createServer((req, res) => {
  // Flag to check if close event is emitted
  let closeEventEmitted = false;

  // Listen for the 'close' event on the response
  res.on('close', () => {
    console.log('Response close event emitted');
    closeEventEmitted = true;
  });

  // Stream response
  res.writeHead(200, { 'Content-Type': 'text/plain' });

  const interval = setInterval(() => {
    res.write('Hello, world!\n');
  }, 100);

  req.on('end', () => {
    clearInterval(interval);
    res.end();
  });

  req.on('error', (err) => {
    console.error('Request error:', err);
    clearInterval(interval);
    res.end();
  });

  // Verify if close event was emitted when the server is closed
  server.on('close', () => {
    assert.strictEqual(closeEventEmitted, true, 'Close event was not emitted on the response');
    console.log('Server closed and close event was verified');
  });
});

// Start the server
server.listen(3000, () => {
  console.log('Server is listening on port 3000');

  // Create a client connection to the server
  const client = net.createConnection({ port: 3000 }, () => {
    console.log('Client connected to server');

    // Write data to the server
    client.write('GET / HTTP/1.1\r\n');
    client.write('Host: localhost\r\n');
    client.write('Connection: close\r\n');
    client.write('\r\n');

    // End the client connection prematurely while reading data
    client.on('data', (data) => {
      console.log('Client received data:', data.toString());
      client.end();
      console.log('Client connection ended prematurely');
    });
  });

  // Set a timeout to give the server time to handle the premature connection end
  setTimeout(() => {
    // Close the server after some time
    server.close(() => {
      console.log('Server closed');
    });
  }, 2000);
});

```
Expected output:
```
➜  node close_event_on_server_node_test.mjs
Server is listening on port 3000
Client connected to server
Client received data: HTTP/1.1 200 OK
Content-Type: text/plain
Date: Mon, 24 Jun 2024 15:58:23 GMT
Connection: close
Transfer-Encoding: chunked

e
Hello, world!


Client connection ended prematurely
Response close event emitted
Request error: Error: aborted
    at abortIncoming (node:_http_server:806:17)
    at socketOnClose (node:_http_server:800:3)
    at Socket.emit (node:events:532:35)
    at TCP.<anonymous> (node:net:338:12) {
  code: 'ECONNRESET'
}
^C
```
Current output:
```
➜  deno run -A close_event_on_server_node_test.mjs
Server is listening on port 3000
Client connected to server
Client received data: HTTP/1.1 200 OK
content-type: text/plain
vary: Accept-Encoding
transfer-encoding: chunked
date: Mon, 24 Jun 2024 15:58:31 GMT

1C
Hello, world!
Hello, world!


Client connection ended prematurely
error: Uncaught (in promise) AssertionError: Close event was not emitted on the response
    at new AssertionError (ext:deno_node/assertion_error.ts:536:11)
    at toNode (node:assert:71:15)
    at Function.strictEqual (node:assert:321:3)
    at ServerImpl.<anonymous> (file:///Users/sr/c/denoland/deno/close_event_on_server_node_test.mjs:36:12)
    at ServerImpl.emit (ext:deno_node/_events.mjs:398:35)
    at node:http:1674:49
    at eventLoopTick (ext:core/01_core.js:168:7)
```