Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: treat aborts the same as before node 16 #7

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions request.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,14 @@ Request.prototype.onRequestResponse = function (response) {
self.emit('end', chunk)
})
responseContent.on('error', function (error) {
if (error.code === 'ECONNRESET' && error.message === 'aborted') {
flotwig marked this conversation as resolved.
Show resolved Hide resolved
// Node 16 causes aborts to emit errors if there is an error listener.
// Without this short-circuit, it will cause unhandled exceptions since
// there is not always an `error` listener on `self`, but there will
// always be an `error` listener on `responseContent`.
// @see https://github.com/nodejs/node/pull/33172
return
}
self.emit('error', error)
})
responseContent.on('close', function () { self.emit('close') })
Expand Down