title: Node.js how to pipe gzip stream to writestream
body: <p>I can't seem to get this to work. I want to write some data to a gzip stream and then pipe the gzip stream to a file write stream. I want to then call a function when the files done writing. I currently have:</p>
  
  <pre><code>  var gz = zlib.createGzip()
                 .pipe(fs.createWriteStream(gz_path));
  
    gz.write(data);
  
    gz.on('error', function(err){
      console.log("wtf error", err);
    });
  
    gz.on('finish', function(){
      console.log("write stream is done");
      dosomething();
    });
  </code></pre>
  
  <p>The finish event or the error event is never called.</p>