await download() stuck when network connection fails
Closed this issue · 6 comments
start download promise will never finish, when network offline.
That looks like a bug. We don't call the callback
when the state is cancelled
:
Line 111 in 1c594cf
I guess we can pass back a special CancelError
maybe. But we also have a onCancel
callback which makes that a bit weird.
@sindresorhus
maybe add some code like
Line 63 in 1c594cf
item.on('updated', (event, state ) => {
//...
if (state === 'interrupted') {
item.cancel();
callback(new Error('download interrupted'));
}
//...
});
I‘ve done something like this and my problem is solved.
That looks like a bug. We don't call the
callback
when the state iscancelled
:Line 111 in 1c594cf
I guess we can pass back a special
CancelError
maybe. But we also have aonCancel
callback which makes that a bit weird.
yeah, you find another bug.
Any plans to fix this bug 😅. I believe the same issue also will occur if you use cancel the download item. I manage to cancel the download, but the download
function never returns, probably due to the same issue.
If anyone wants to work on this, see the feedback in #142.