Closed AS-Omar closed 2 years ago
If you could share your code snippet, error message and Node version, I'd take a look at what's going on :)
Here's the code snippet (which works with v1.0.18):
downloader = new DownloaderHelper(fileUrl, downloadDirectory, {
fileName: fileName,
override: true,
retry: { maxRetries: 3, delay: 1000 },
removeOnStop: false,
removeOnFail: false
})
downloader.__total = fileSize
downloader.__filePath = path.join(downloadDirectory + fileName)
downloader.__downloaded = downloader.__getFilesizeInBytes(downloader.__filePath)
downloader.__isResumable = true
downloader.resume()
When I call downloader.resume()
, I get the this: TypeError: Cannot read property 'resolve' of null
.
The Node.js version is 14.16.0 (which comes bundled with Electron 13.6.2).
Any fix ever come for this? Running into the same issue with 1.0.19 running Node 16.9.1 (Electron v16.0.7). If I downgrade to v1.0.18 it works without issue
okay so it looks like there's a bit more going on than I initially thought, I'll take a closer look at it over the coming days :)
@Chaphasilor is this covered with your PR #76 ?
Nope, didn't get around to this just yet. There was some refactoring and internal method renaming from 1.0.18 to 1.0.19 that seems to be causing this issue...
@Chaphasilor not a problem, i though was related, i will take a look on my part 👍🏽
Found a walk around like this
downloader.__total = fileSize;
downloader.__filePath = path.join(downloadDirectory + fileName);
downloader.__downloaded = downloader.__getFilesizeInBytes(downloader.__filePath);
downloader.__setState(downloader.__states.RESUMED);
downloader.__isResumed = true;
downloader.__options['headers']['range'] = 'bytes=' + downloader.__downloaded + '-';
downloader.start();
It's very dirty, but works. I wish this could be implemented as a spec.
Implemented resume from file in 2.1.0
I was using this workaround you posted for resuming downloads after restarting the Electron app: https://github.com/hgouveia/node-downloader-helper/issues/13#issuecomment-637779060
It was working fine with v1.0.18. However, after upgrading to v1.0.19, this workaround is no longer working and throws an error. Can the workaround be modified so that it works with v1.0.19?