const http = require('http');
const net = require('net');
const request = http.get('http://example.com', {
createConnection: () => null
});
request.once('error', console.error);
request.destroy(new Error('Oh no.'));
Always.
Error: Oh no.
(hangs indefinitely)
The problem here is that it doesn't use the proper destroy implementation. Some work in this regard is being done over here https://github.com/nodejs/node/pull/33035. I've been mostly focusing on undici lately but hope to start helping out over there as well at some point.
@szmarczak Could test the branch of #33035 (if you have the time) to see if the problem still persists? The emitting of the error event is something that I am trying to figure out in that PR. The current behavior is that the event is emitted only if there are listeners attached to it.
The branch I suggested does nothing about this problem which is more related to the ClientRequest itself and not to IncomingMessage. Sorry for spamming.
Most helpful comment
The problem here is that it doesn't use the proper destroy implementation. Some work in this regard is being done over here https://github.com/nodejs/node/pull/33035. I've been mostly focusing on undici lately but hope to start helping out over there as well at some point.