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

fs: fix fd leak on early readstream destroy #81

Closed
wants to merge 1 commit into from

Conversation

mafintosh
Copy link
Member

Currently the following leaks a file descriptor

var fs = require('fs')

var rs = fs.createReadStream('my-file.txt')

rs.on('close', function() {
  console.log('i am never fired')
})

rs.destroy()

In fact if you call rs.destroy() before open has been emitted in general the read stream never closes.

This PR fixes that by calling .close() when the file descriptor is opened incase the stream has been destroyed in the meanwhile

@mafintosh
Copy link
Member Author

Oh I see this is a dup of #56. Closing.

@mafintosh mafintosh closed this Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant