Git Product home page Git Product logo

Comments (3)

ZJONSSON avatar ZJONSSON commented on August 20, 2024
  1. This is not a typo. The .pipe(destination) returns destination (see stream) so both implementations should work.
  2. You do not need to include a promise library directly. If the promise is not called in your example it is possible that the object.createReadStream() didn't end? You can verify by putting .on('end', () => console.log('input stream ended')) right after the .createReadStream()

The promise behaviour is tested here: https://github.com/ZJONSSON/node-unzipper/blob/master/test/parsePromise.js - please take a look and see if the test work when you adjust it to your example?

from node-unzipper.

DazWilkin avatar DazWilkin commented on August 20, 2024

Thank you for the prompt response @ZJONSSON.

It appears this is exactly my problem...

The library I'm using is not triggering end, error or finish events even though the file is definitively created. Will pursue with those folks, thank you!

from node-unzipper.

ZJONSSON avatar ZJONSSON commented on August 20, 2024

Thanks for letting me know @DazWilkin . The input stream might possibly be missing the last bytes of the file as well, as the unzipper.Parse() actually closes when the zip file is complete even though a formal end event hasn't been received.

In any case, if you are getting all the zip entries you need through, you could "fake" an end in a hacky way, if the input stream has remained silent for a time that is longer than any latency period in the pipeline.

Something like:

const Stream = require('stream');

class TimeoutStream extends Stream.Transform {
  constructor(timeout) {
    super();
    this.timeout = timeout;
  }

  _transform(d, e, cb) {
    clearTimeout(this._timeout);
    this._timeout = setTimeout( () => this.end(), this.timeout);
    cb(null, d);
  }
}

object.createReadStream()
    .pipe(new TimeoutStream(1000))   // automatically end after 1 sec inactivity
    .pipe(unzipper.Parse())
     ......

Closing this - please post any new findings or reopen if you find any related unzipper issues.

from node-unzipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.