Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,24 +752,10 @@ function socketErrorListener(err) {
debug('SOCKET ERROR:', err.message, err.stack);

if (req) {
const res = req.res;
const isUserDestroyError = err === req[kError] || err === res?.errored;

// For Safety. Some additional errors might fire later on
// and we need to make sure we don't double-fire the error event.
socket._hadError = true;
// Before a response exists, the request itself failed. Once a response
// exists, socket teardown belongs to the IncomingMessage and is finalized
// by socketCloseListener. Preserve errors explicitly used to destroy the
// request or response, which have historically been emitted on the request.
if (!res || isUserDestroyError) {
emitErrorEvent(req, err);
}

if (res) {
socket.destroy();
return;
}
emitErrorEvent(req, err);
}

const parser = socket.parser;
Expand Down
55 changes: 0 additions & 55 deletions test/parallel/test-http-client-complete-response-reset.js

This file was deleted.

Loading