From 42981e2aadfdf1a16218dced31e55d9f62020c4d Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 4 Dec 2012 17:20:12 -0800 Subject: [PATCH] streams2: Switch to old-mode immediately, not nextTick This fixes the CONNECT/Upgrade HTTP functionality, which was not getting sliced properly, because readable wasn't emitted on this tick. Conflicts: test/simple/test-http-connect.js --- lib/_stream_readable.js | 4 +--- test/simple/test-http-connect.js | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index ac21330dfe..a0cb13c3f9 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -568,9 +568,7 @@ function emitDataEvents(stream) { }; // now make it start, just in case it hadn't already. - process.nextTick(function() { - stream.emit('readable'); - }); + stream.emit('readable'); } // wrap an old-style stream as the async data source. diff --git a/test/simple/test-http-connect.js b/test/simple/test-http-connect.js index 668dda7963..3643cec18e 100644 --- a/test/simple/test-http-connect.js +++ b/test/simple/test-http-connect.js @@ -73,7 +73,11 @@ server.listen(common.PORT, function() { assert(!socket.onend); assert.equal(socket.listeners('connect').length, 0); assert.equal(socket.listeners('data').length, 0); - assert.equal(socket.listeners('end').length, 0); + + // the stream.Duplex onend listener + // allow 0 here, so that i can run the same test on streams1 impl + assert(socket.listeners('end').length <= 1); + assert.equal(socket.listeners('free').length, 0); assert.equal(socket.listeners('close').length, 0); assert.equal(socket.listeners('error').length, 0);