Node: `error` event not emitted when destroying an HTTP request without a socket

Created on 6 Aug 2020  路  3Comments  路  Source: nodejs/node

  • Version: v14.5.0
  • Platform: Linux solus 5.6.19-158.current #1 SMP PREEMPT Sun Jul 26 14:17:01 UTC 2020 x86_64 GNU/Linux
  • Subsystem: http

What steps will reproduce the bug?

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.'));

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Error: Oh no.

What do you see instead?


(hangs indefinitely)

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielstaleiny picture danielstaleiny  路  3Comments

mcollina picture mcollina  路  3Comments

cong88 picture cong88  路  3Comments

loretoparisi picture loretoparisi  路  3Comments

dfahlander picture dfahlander  路  3Comments