Streams2 coming in Node.js v0.10.x breaking compatibility for some programs

Date: Sat Apr 26 2014 Compatibility »»»» Streams2 »»»» 0.10.x »»»» Stream
I didn't know that Node.js streams were suboptimal but it seems the Node core team thinks so.  Over on the Node.js blog, Isaac Schleuter just announced that for the upcoming v0.10.x phase of Node, the Stream module will be replaced by Streams2, with much better API's though with a small bit of incompatibility.  Most of the existing Stream methods will work, but there is one bit of incompatibility - previously a program did not have to call the resume method for data events to begin occurring.  With Streams2 these programs must call resume first.

Specifically, this no longer works:

// WARNING! BROKEN!
net.createServer(function(socket) {

// we add an 'end' method, but never consume the data
socket.on('end', function() {
// It will never get here.
socket.end('I got your message (but didnt read it)\n');
});

}).listen(1337);

Instead you must do it this way

// Workaround
net.createServer(function(socket) {

socket.on('end', function() {
socket.end('I got your message (but didnt read it)\n');
});

// start the flow of data, discarding it.
socket.resume(); // <---- NEW REQUIREMENT

}).listen(1337);


Full details are on the nodejs.org blog.  See also this: a talk in November