Description
This is an issue that got stuck in the Node repo due to concerns of breaking the ecosystem. Thought it might be worth a quick look in this group to see whether we find a solution we haven't considered yet?
The problem here is that instead of emitting an ECONNRESET
'error'
on the IncomingMessage
object we emit 'aborted'
which is surprising when the object is sent in a function that expects a regular stream.
function myStreamProcessor(stream, cb) {
// Stream logic that will deadlock if stream
// is an `IncomingMessage` since it does not listen to `'aborted'`
stream
.on('error, cb)
.on('data', /* do something */)
.on('end', cb)
}
The current workaround, which is probably good enough for most cases, is to encourage usage of pipeline
which properly handles/normalizes this issue.
This is not a totally uncommon issue, e.g. I saw it recently at https://github.com/szmarczak/http-timer (3,233,355 weekly downloads) where an 'aborted'
listener is missing and instead an 'error'
listener is registered.
nodejs/node#28172 (issue)
nodejs/node#28677 (closed proposal PR)
I would recommend a read through of the comments for PR above to understand existing concerns.