ClientRequest `.abort()` and `ECONNRESET`

Continuing the discussion from #32182 (comment)

The current assumption is that always 'error' or 'response' is emitted on the socket.

However, this is not always the case. Consider:

const req = http.get(someUrl);
req.abort();
req.on('error', common.mustCall()); // Fails

This will fail because the case of calling req.abort() before 'socket' will actually result in no error. Whether we get an error or not is a question of timing.

The current semantics are:

  • If abort() before req.'socket', emit req.'close'.
  • If abort() after req.'socket' but before req.'response', emit req.'error'.
  • If abort() after req.'response', emit req.'close' & res.'aborted'.

My main concern (which breaks the above assumption) is the first scenario here. However, I noticed that fixing this will cause lots of other tests to fail.

What can/should we do about this? At a minimum I'd like to clarify the docs.