-
Notifications
You must be signed in to change notification settings - Fork 116
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
promise warnings on latest node #73
Comments
Thanks @contra. So this is tricky because autodrain returns a promise that could be of use (i.e. resolve when success or reject when error). So I'm not sure that the fix here is to remove the promise altogether. If you either |
@ZJONSSON Yeah, adding entry.autodrain = function() {
__autodraining = true;
return {
promise: function() {
return new Promise(function(resolve,reject) {
entry.pipe(NoopStream());
entry.on('finish',resolve);
entry.on('error',reject);
});
}
};
}; So if you did want to await it, it's |
You still would have to actually pipe the entry into a Also if you are not interested in the promise, handling any errors that might occur in autodraining can be problematic (the error event handler is not accessible). One way to solve this would be to return a stream that passes no data, but includes the error event handlers, but also includes a Something like this: entry.autodrain = function() {
__autodraining = true;
var draining = entry.pipe(NoopStream();
draining.promise = function() {
draining.on('finish',resolve);
draining.on('error',reject);
};
return draining;
} Here you could then do The problem with above suggestions is that both bring breaking changes, which I try to avoid unless there is a larger change to the API. Maybe the right solution would be to allow the first argument to be "noPromise". i.e.: entry.autodrain = function(noPromise) {
__autodraining = true;
var draining = entry.pipe(NoopStream();
if (noPromise) return draining;
draining.promise = function() {
draining.on('finish',resolve);
draining.on('error',reject);
};
return draining;
} No argument is currently defined on What do you think? |
Is it documented anywhere that this returns a promise? I’m open to either, i believe in pulling bandaids but up to you if you think it’s worthy of a major bump. |
My last suggestion would not require a bump, and would allow you the same interface as you suggested, except you would have to |
@ZJONSSON Yeah, that works |
Hey @contra I looked more closely at this and I agree with you, i.e. as the returned promise is neither in documents nor any of the tests and examples we can just make the switch. Did a PR but some of test that rely on external urls are failing. Probably unrelated, will look into that separately. |
published as |
On latest node. Just using this in a basic way - for each file, pipe it to the fs. Seems like this is caused by this promise being created in autodrain, which I'm not using: https://github.com/ZJONSSON/node-unzipper/blob/master/lib/parse.js#L85
The text was updated successfully, but these errors were encountered: