-
Notifications
You must be signed in to change notification settings - Fork 30
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
Close getting fired before finishing Transform on all files #23
Comments
Right, atm the only guarantee with the Parse stream is that 'end' is emitted after all entries, not necessarily after the transform callbacks finished. Here's one way to deal with it using promises - #22 (comment) But I agree that your example should just work, unfortunately because of multiple levels of buffering it doesn't. |
Shouldn't be below? diff --git a/lib/parser-stream.js b/lib/parser-stream.js
index f124407..0205488 100644
--- a/lib/parser-stream.js
+++ b/lib/parser-stream.js
@@ -20,6 +20,9 @@ function ParserStream(opts) {
this.unzipStream.on('error', function(error) {
self.emit('error', error);
});
+ this.unzipStream.on('end', function() {
+ process.nextTick(function() { self.emit('close'); });
+ });
}
util.inherits(ParserStream, Transform);
@@ -31,7 +34,6 @@ ParserStream.prototype._transform = function (chunk, encoding, cb) {
ParserStream.prototype._flush = function (cb) {
var self = this;
this.unzipStream.end(function() {
- process.nextTick(function() { self.emit('close'); });
cb();
});
} The current implementation emits However, as Node.js specification, Also, |
Oh, but some tests come to fail. |
I have a zip file with multiple files. the problem here is that close fires before all Transforms are done.
What I want is to fire code in the
unzipParser.on('close'
after all entries was processed bytransform: function(entry,e,cb) {
Also note that I do not know the number of files in the zip as this can be any number.
My Current Example (Not working as close is getting fired before all entries was read through the transform function):
The text was updated successfully, but these errors were encountered: