Closed
Description
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()
beforereq.'socket'
, emitreq.'close'
. - If
abort()
afterreq.'socket'
but beforereq.'response'
, emitreq.'error'
. - If
abort()
afterreq.'response'
, emitreq.'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.