-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix maximum call stack size exceeded #23
base: master
Are you sure you want to change the base?
Conversation
Correctly consumes variable length file data when no entry lisener has been registered and unzip.Parse receives the data as multiple chunks. Without this fix, unzip.Parse always stops piping variable length file data after the first chunk is sent to zlib.
setImmediate happens on the next tick and allows I/O, causing writes to the MatchStream after it should have ended. Only fixes this issue in Node 0.10.x. In node 0.8.x, process.nextTick has similar behavior to setImmediate.
Recursively calling Parse._flush caused recursive process.nextTick calls. Fixes #16.
To be node 0.8.x compatible, Parse can't process variable length file data in a way that's dependent on process.nextTick behavior - this is what currently happens inside of the function passed to the MatchStream constructor in Parse which is called when the MatchStream reaches the end of the file length data, indicated by the data descriptor signature. The solution I'm kicking around is to modify the match-stream module's API to take the original function called once the descriptor has been reached as well as a callback that fires when the match-stream ends. The new callback would return any data additional data (i.e. data past the descriptor signature) stored in the MatchStream's internal read queue. So instead this section of Parse looks something like this: ...
//if (!fileSizeKnown)
var descriptorSig = new Buffer(4);
descriptorSig.writeUInt32LE(0x08074b50, 0);
var matchStream = new MatchStream({ pattern: descriptorSig }, function (buf, matched) {
if (!matched) {
return hasEntryListener ? this.push(buf) : null;
}
if (hasEntryListener) {
this.push(buf);
}
return this.push(null); //end matchStream
}, function (err, extra) {
if (err) return self.emit(err);
self._pullStream.prepend(extra);
self._processDataDescriptor(entry);
});
self._pullStream.pipe(matchStream);
if (hasEntryListener) {
matchStream.pipe(inflater).pipe(entry);
} |
I added 548c16b, but entries sometimes fail to emit |
@EvanOxfeld good to know you're almost there. I don't know if you're testing a lot of zip files but it would be good to test zip files generated by common tools on unix, windows and macosx so cover most cases. Tell me if you need help getting those integrated. |
Please see #24 regarding tests and persisting failures |
Bump! |
@EvanOxfeld we've managed to fix bower extraction of zip files for both node zlib.Z_DEFAULT_CHUNK = 1024*8; Hope that helps. |
Bump |
please merge, @nearinfinity ! :) |
Has there been any progress on this? I was trying out this library tonight and unfortunately hit this snag on one of the zip files I was working with, and this branch did indeed fix the issue. |
Thanks for this patch which fixes the issue here on a node 0.10. |
Circled back to the project depending on this, this still appears to be an issue. Using this branch alone no longer resolves the problem, however, updating the references to process.nextTick in the pullstream dependency seems to do the trick. Is there any chance this will be resolved soon? |
I faced this today while unzipping a big file.Is this getting fixed any time soon ? |
@EvanOxfeld, you haven't made any changes for 9 months; @joeferner for 2 years. You're active with other projects, just not this one. Meanwhile, there's plenty of activity around this project driven by its need for maintenance. It might be time to @enyojs, @YuriMilchev, @tsouza, @shannonmpoole, @lloydsheng, @kenvifire, @zauberlabs, @jeanlauliac, @TimNZ, @wibblymat, and @proxv: if @EvanOxfeld stays dormant, or if he wakes up but only to hand it over: around which of your forks should we consolidate, merge #23, apply all your fixes to |
I would have to say my fork probably isn't the best choice. I just tweaked the size check and have since moved on from using the library all together. I've found I could accomplish what I needed using zlib and tar. |
See #50 (Should this project have a future?) for related discussion. |
Most of the way fix for #16. Working in node 0.10.3 on jquery-ui-1.10.0.custom.zip but not in node 0.8.x testing against
Current hang up is 34f30cc and more specifically the MatchStream starting on parse.js line 158. For archives that contain variable length file data, unzip.Parse needs to stop sending data to the zlib inflater stream when the data descriptor signature is reached. In Node 0.10.x the MatchStream stops the flow of data correctly because the process.nextTick on line 165 happens on the current tick before I/O. Unfortunately, in Node 0.8.x I/O can happen before a process.nextTick, which causes extra writes to the MatchStream and erroneous data to flow into the zlib inflater stream.
Feedback is much appreciated.
/cc @satazor