Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end and finish event not firing via SPDY #34

Closed
heri16 opened this issue Jan 28, 2015 · 3 comments
Closed

end and finish event not firing via SPDY #34

heri16 opened this issue Jan 28, 2015 · 3 comments

Comments

@heri16
Copy link

heri16 commented Jan 28, 2015

I am creating an array of fs.createReadableStreams and putting them into a message. This message is then passed to my jschan/graft microservice, which pipes each file it into local fs.createWritableStreams.

Data, end, and finish events fire correctly when I am using the in-memory graftJS, and also when using spdy on localhost with a small file (< 3746 bytes). However, all three of the same events fail to fire when sending larger files over spdy jschan.

Node version is v0.10.35

Sender:

    // Convert filePaths into filestreams that can be sent via graft jschan
    if (msg.filePaths) {
      var fileStreams = {};
      msg.filePaths.forEach(function(filePath) {
        var fileName = path.basename(filePath);
        //var zlibCompress = zlib.createDeflate();
        var fileStream = fs.createReadStream(filePath);

        fileStream.resume();
        fileStream.on('data', function(chunk) {
          console.log('got %d bytes of data', chunk.length);
        });
        fileStream.on('end', function() { console.log('end'); });

        fileStreams[fileName] = fileStream;
      });
      msg.fileStreams = fileStreams;
    }

Receiver:

        // Save remote fileStreams to local temp directory.
        async.map(Object.keys(msg.fileStreams), function _writeStream(fileName, cb) {
          var fileStream = msg.fileStreams[fileName];
          var outPath = path.join(dirPath, fileName);
          var outStream = fs.createWriteStream(outPath);
          console.log(outPath);

          // end event does not fire
          fileStream.resume();
          fileStream.on('data', function(chunk) {
            console.log('got %d bytes of data', chunk.length);
          });
          fileStream.on('end', function() { console.log('end'); });

          // finish event does not fire 
          fileStream.pipe(outStream).on('error', function(err) {
            setImmediate(cb, err);
          }).on('finish', function() {
            setImmediate(cb, null, outPath);
          });

        }, function(err, filePaths) {
          if (err) { cleanupTmp(); throw err; }
          ...
        });

Would really appreciate the help nailing this bug down.

@mcollina
Copy link
Contributor

Sorry for the late reply, I have very low bandwidth for this now.

Can you please test #32? It might solve the issue, in case I'll get it released.

@AdrianRossouw
Copy link
Contributor

i merged that change, and we also moved the spdy transport to a separate repo.

recreate there if this still exists.

https://github.com/GraftJS/jschan-spdy

@heri16
Copy link
Author

heri16 commented Oct 23, 2015

Is this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants