mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
streams2: NextTick the emit('readable') in resume()
Otherwise resume() will cause data to be emitted before it can be handled.
This commit is contained in:
@@ -545,6 +545,7 @@ function emitDataEvents(stream, startPaused) {
|
||||
|
||||
stream.on('readable', function() {
|
||||
readable = true;
|
||||
|
||||
var c;
|
||||
while (!paused && (null !== (c = stream.read())))
|
||||
stream.emit('data', c);
|
||||
@@ -562,7 +563,9 @@ function emitDataEvents(stream, startPaused) {
|
||||
stream.resume = function() {
|
||||
paused = false;
|
||||
if (readable)
|
||||
stream.emit('readable');
|
||||
process.nextTick(function() {
|
||||
stream.emit('readable');
|
||||
});
|
||||
};
|
||||
|
||||
// now make it start, just in case it hadn't already.
|
||||
|
||||
Reference in New Issue
Block a user