Skip to content
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

await download() stuck when network connection fails #115

Closed
Topppy opened this issue Jun 29, 2020 · 6 comments · Fixed by #164
Closed

await download() stuck when network connection fails #115

Topppy opened this issue Jun 29, 2020 · 6 comments · Fixed by #164

Comments

@Topppy
Copy link

Topppy commented Jun 29, 2020

start download promise will never finish, when network offline.

@sindresorhus
Copy link
Owner

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.

@Topppy
Copy link
Author

Topppy commented Jun 29, 2020

@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.

@Topppy
Copy link
Author

Topppy commented Jun 29, 2020

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.

@follesoe
Copy link

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.

follesoe added a commit to follesoe/electron-dl that referenced this issue Oct 20, 2021
To ensure the function does not get stuck in this state, using a custom CancelError type.
@sindresorhus
Copy link
Owner

If anyone wants to work on this, see the feedback in #142.

@k2s
Copy link
Contributor

k2s commented Oct 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants