Reputation: 18905
I'm getting a readable stream (require('stream').Readable
) from a library I'm using*.
In a general sense, how can I close this (any) readable stream once all data is consumed? I'm seeing the end
event, but the close
event is never received.
Tried: .close()
and destroy()
don't seem to be avail anymore on require('stream').Readable
, while they were avail on require('fs') streams
.
I believe the above is causing some erratic behavior under load. I.e.: running out of file descriptors, mem leaks, etc, so any help is much appreciated.
Thanks.
*) x-ray. Under the covers it uses enstore, which uses an adapted require('stream').Readable
Upvotes: 0
Views: 1390
Reputation: 106696
Readable streams typically don't emit close
(they emit end
). The close
event is more for Writable streams to indicate that an underlying file descriptor has been closed for example.
There is no need to manually close a Readable stream once all of the data has been consumed, it ends automatically (this is done when the stream implementation calls push(null)
).
Of course if the stream implementation isn't cleaning up any resources it uses behind the scenes, then that is a bug and should be filed on the appropriate project's issue tracker.
Upvotes: 1