You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
It seems that when a stream ends, and it still has unread data in its buffers, a final readable event gets emitted, and stream.read(n) where n > unread.length happily returns the remaining bytes even though it normally wouldn't.
(i.e. just before ending, it returned what it had, instead of the requested amount)
This behavior is surprising because the documentation lets you believe that stream.read(n) can only ever return the requested amount of bytes:
If you pass in a size argument, then it will return that many bytes. If size bytes are not available, then it will return null.
I was able to dig a removed explanation for this behavior, and I'm not necessarily questioning the validity of it, but it seems very odd and confusing that none of this is documented and even the useful comment has been removed.