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

Unexpected call to flush after transform stream destruction #18172

Closed
mafintosh opened this issue Jan 16, 2018 · 3 comments
Closed

Unexpected call to flush after transform stream destruction #18172

mafintosh opened this issue Jan 16, 2018 · 3 comments
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@mafintosh
Copy link
Member

Running the below example

var stream = require('stream')

var t = stream.Transform({
  transform: function (data, enc, cb) {
    console.log(`transform destroyed=${this._readableState.destroyed}`)
    cb(null)
  },
  flush: function (cb) {
    console.log(`flush destroyed=${this._readableState.destroyed}`)
    cb(null)
  }
})

t.on('close', function () {
  console.log('onclose')
})

t.on('error', function () {
  console.log('onerror')
})

t.on('end', function () {
  console.log('onend')
})

t.on('finish', function () {
  console.log('onfinish')
})

t.resume()
t.write('a')
t.write('b')
t.write('c')
t.destroy(new Error('error'))

... I get the following output

transform destroyed=false
transform destroyed=false
transform destroyed=false
flush destroyed=true
onfinish
onend
onclose
onerror

The order of events here seem wrong (similar to #18171) as I would expect error to come before finish/end.

It also seems wrong that flush is called even though the stream has been destroyed.

@mafintosh
Copy link
Member Author

/cc @mcollina @nodejs/streams

@AndreasMadsen AndreasMadsen added the stream Issues and PRs related to the stream subsystem. label Jan 16, 2018
@BridgeAR
Copy link
Member

@mafintosh @nodejs/streams what's the status here?

@mcollina
Copy link
Member

This was fixed in Node 10 by #19836

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants