Giter Club home page Giter Club logo

Comments (9)

zcbenz avatar zcbenz commented on May 6, 2024

I am sure that the underlying native code works fine, since piping the file stream to process.stdout works as expected, so the bug must hides in the unzip module's code, I guess it's related to how process.nextTick is implemented in atom-shell.

It would take me some time to find it out since unzip has used many third party modules.

from electron.

zcbenz avatar zcbenz commented on May 6, 2024

This bug is again caused by the setImmediate function.

The unzip module uses setImmediate in Parse.prototype._flush to wait for more data when the file was read but the data was not completely parsed. This trick relies on this behavior: the setImmediate should run the callback after other uv operations, however since the setImmediate is implemented via WebKit's setTimeout, the callback passed would be scheduled to run in WebKit's message loop, which is independent with uv loop, so it happens that the callback passed in setImmediate just keeps running but the other operations pending in uv loop just do not get a chance to run, until something accidentally activates the uv loop.

Implementing the setImmediate with node's timers module would fix this.

The process.nextTick implementation in atom-shel does have the same problem with setImmediate, and I doubt atom/atom@70e414b is caused by this. I'll switch both functions to use their original implementations.

from electron.

zcbenz avatar zcbenz commented on May 6, 2024

Fixed with 25d9c1a and electron/node@4b4c40a.

Instead of using node's original implementation of setImmediate, I just make sure when setImmediate is called the uv loop would also be activated (or interrupted), so it can have the behavior expected by unzip module. Using node's setImmediate would cause interleaves of two message loops and two V8 contexts, which is the thing I want to avoid most.

from electron.

kevinsawicki avatar kevinsawicki commented on May 6, 2024

👍 awesome, thanks for the quick fix!

from electron.

nathansobo avatar nathansobo commented on May 6, 2024

Is this something that Ben Noordhuis' changes to node to support multiple
contexts would fix?

On Tue, Jul 9, 2013 at 9:49 AM, Kevin Sawicki [email protected]:

[image: 👍] awesome, thanks for the quick fix!


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-20683820
.

from electron.

zcbenz avatar zcbenz commented on May 6, 2024

@nathansobo no, this is caused by our message loop integration, we have to use this solution unless node supports multiple message loops (which I don't think node would ever do, they gave up once when trying to adding isolates to node).

from electron.

kevinsawicki avatar kevinsawicki commented on May 6, 2024

Has this been released?

from electron.

zcbenz avatar zcbenz commented on May 6, 2024

Yes it has been released, but I found it only fixed zip files of smaller sizes, there must have been some other bugs.

from electron.

zcbenz avatar zcbenz commented on May 6, 2024

Fixed with electron/node@d0ccec3.

Now atom-shell just uses node's implementation of setImmediate, otherwise it's quite hard to make unzip work as expected.

from electron.

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.