-
Notifications
You must be signed in to change notification settings - Fork 35
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
ReadableStreamBuffer stalls if not used right away #30
Comments
Confirmed. Easy to reproduce as well: const {ReadableStreamBuffer} = require('stream-buffers')
const readable = new ReadableStreamBuffer()
readable.on('data', (data) => {
console.log('data:', data.toString())
})
readable.on('end', () => {
console.log('end')
})
setTimeout(() => {
console.log('putting')
readable.put('abcdef')
readable.stop()
}, 100) |
Confirmed - my first NodeJS project ever - I ran into this in /node_modules/lib/streambuffers/readable_streambuffer.js this seems to be the culprit: _read probably was underscored indicating it's private and shouldn't be overloaded. The function gets called right away regardless the TimeOut spficied for the StreamBuffer. It finds an empty buffer, returns false, and kille the timer - result: StreamBuffer is now dead.
de |
The override of _read here is fine, as documented here https://nodejs.org/api/stream.html#stream_implementing_a_readable_stream The issue is as follows:
I'd love to get input on a fix before I make a pull request. |
Fix Issue #30 where ReadableStreamBuffer stalls in certain cases.
|
I think this issue can be marked as resolved :) |
where ReadableStreamBuffer stalls in certain cases.
Agreed.
…On Fri, Aug 31, 2018, 2:12 AM Genry Manashirov ***@***.***> wrote:
I think this issue can be marked as resolved :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUiTTUvogFUNmAvDiCqVNLveYYSdZUHks5uWO_xgaJpZM4LvdPN>
.
|
I instantiated a ReadableStreamBuffer, attached a 'data' event, and called an asynchronous call which took much longer than the
frequency
of the running timeout. In the initial run ofsendData
,amount
was zero sosendMore
was false and the timer did not continue to run. Only after that did my data come in, and I calledput()
but the contents were never seen by the observer.My workaround was to call
_read()
to wake up the stream.The text was updated successfully, but these errors were encountered: