Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGil Pedersen <git@gpost.dk>2013-03-17 18:04:01 +0400
committerisaacs <i@izs.me>2013-03-22 04:49:12 +0400
commitc3aae9cf95749949194f5288bad7468a995b1162 (patch)
treed21a4f308bd0e36f5598493f6825d6854b469f8c /test
parentbfd16de125020551bf6fac42c01bc63d5fab90f5 (diff)
stream: Fix stall in Transform under very specific conditions
The stall is exposed in the test, though the test itself asserts before it stalls. The test is constructed to replicate the stalling state of a complex Passthrough usecase since I was not able to reliable trigger the stall. Some of the preconditions for triggering the stall are: * rs.length >= rs.highWaterMark * !rs.needReadable * _transform() handler that can return empty transforms * multiple sync write() calls Combined this can trigger a case where rs.reading is not cleared when further progress requires this. The fix is to always clear rs.reading.
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-stream2-transform.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js
index 500c48b8ac0..7a32a3cce8b 100644
--- a/test/simple/test-stream2-transform.js
+++ b/test/simple/test-stream2-transform.js
@@ -235,6 +235,42 @@ test('assymetric transform (compress)', function(t) {
});
});
+// this tests for a stall when data is written to a full stream
+// that has empty transforms.
+test('complex transform', function(t) {
+ var count = 0;
+ var saved = null;
+ var pt = new Transform({highWaterMark:3});
+ pt._transform = function(c, e, cb) {
+ if (count++ === 1)
+ saved = c;
+ else {
+ if (saved) {
+ pt.push(saved);
+ saved = null;
+ }
+ pt.push(c);
+ }
+
+ cb();
+ };
+
+ pt.once('readable', function() {
+ process.nextTick(function() {
+ pt.write(new Buffer('d'));
+ pt.write(new Buffer('ef'), function() {
+ pt.end();
+ t.end();
+ });
+ t.equal(pt.read().toString(), 'abc');
+ t.equal(pt.read().toString(), 'def');
+ t.equal(pt.read(), null);
+ });
+ });
+
+ pt.write(new Buffer('abc'));
+});
+
test('passthrough event emission', function(t) {
var pt = new PassThrough();