Monday, 3 April 2017

Problems superclassing stream.Duplex

I am trying to implement a readable stream by extending stream.Readable.

According to the docs all I have to do is implement _read().

What I do not understand is what to do when in _read I have no data or how to trigger another call to _read once I do have data again. I do not see a concept in Readable to cope with data being delivered slowly or delayed. I can see that _read() is being called right after the pipe() function was called.

If at any point in _read I have no data I have to return without delivering and it seems that _read is never called again. I tried to emit a readable event once data is ready but that doesn't trigger a call to _read.

This problem does not only occur on start, but might happen whenever my source takes its time to deliver. Does stream.Readable not support slow sources ?



via Thomas

No comments:

Post a Comment