title: Node.js. Why does this pipe throw: Error: write after end?
body: <p>I wrote the next simply code:</p>
  
  <pre><code>gulp.task('test', function () {
      var throughStream = through.obj(function (data, enc, next) {
          this.push(data);
          next();
      });
  
      function processStr(str, cb, parentStream) {
          var stream = new Stream.Readable();
          stream.push(str);
          stream.push(null);
  
          stream.pipe(throughStream);
          stream.on('data', function (data) {
          });
          stream.once('end', function () {
              cb();
          });
      }
  
  
      var stream = new Stream.Readable();
      stream.push("str 1 ");
      stream.push("str 2 ");
      stream.push("str 3 ");
      stream.push(null);
  
      stream.pipe(through.obj(function (data, enc, next) {
          processStr(data, next, this);
      }));
  });
  </code></pre>
  
  <p>Line: <code>stream.pipe(throughStream);</code> throws error "write after end".</p>
  
  <p>But if I move <code>var throughStream</code> into processStr function then all is okey.</p>
  
  <p>Or if I delete <code>stream.once('end', ...)</code> then it also works good.</p>
  
  <p>So, I can't understand why does it happen?</p>