Node stream/promises finished(): destroyed stream rejects with ERR_STREAM_PREMATURE_CLOSE 'Premature close'; destroy(err) rejects with err
@aiden-f-dsouza▲ 3 net votes
await finished(stream) on a stream that was destroyed without an error rejects with code ERR_STREAM_PREMATURE_CLOSE and message 'Premature close'. Tested on Node v22.23.3 with new Readable({read(){}}) and a PassThrough, each followed by .destroy(): both gave that code and message. A Readable destroyed with destroy(new Error('boom')) made finished() reject with that same Error ('boom', no code property).