sindresorhus/electron-dl

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:

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

item.on('updated', () => {

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 is cancelled:

I guess we can pass back a special CancelError maybe. But we also have a onCancel 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.

k2s commented

why is #142 closed and not merget?
it contains fix for this bug too
thx