- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.6k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- Version: 8.9.4
- Platform: Linux brunhilde 4.14.9-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Tue Dec 26 00:18:37 UTC 2017 x86_64 GNU/Linux
- Subsystem: streams
Running the below example
var stream = require('stream')
var rs = new stream.Readable({read: () => {}})
rs.on('end', function () {
  console.log('onend')
})
rs.on('error', function () {
  console.log('onerror')
})
rs.resume()
rs.read()
rs.destroy(new Error('error'))... I get the following output
onend
onerror
This was confusing to me as I would expect a stream.destroy(err) to result in an immediate error event (especially before any end was emitted under the hood).
This order of events makes error handling hard as everything looks like it ended as it should when the end is emitted before the error.
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.