Files
node/test/parallel
RajeshKumar11 b75073d5aa http: attach error handler to socket synchronously in onSocket
Between onSocket and onSocketNT, the socket had no error handler,
meaning any errors emitted during that window (e.g. from a blocklist
check or custom lookup) would be unhandled even if the user had set up
a request error handler.

Fix this by attaching socketErrorListener synchronously in onSocket,
setting socket._httpMessage so the listener can forward errors to the
request. The _destroy path in onSocketNT is also guarded to prevent
double-firing if socketErrorListener already emitted the error.

Fixes: https://github.com/nodejs/node/issues/48771
Refs: https://github.com/nodejs/node/pull/61658
PR-URL: https://github.com/nodejs/node/pull/61770
Refs: https://github.com/nodejs/node/issues/48771
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-07-19 17:30:42 -05:00
..