You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
electron-auto-updater request can download so fast that the first few chunks arrive before ensureDirPromise has finished for configurePipes to run
#1081
Hi, I have electron-auto-updater setup to download from a generic server.
I have been having issues of getting an error: "Error: SHA2 checksum mismatch, expected xxx, got xyx" (different hashes each time I build different setup files).
I had a look at the downloaded files, and noticed that some parts at the beginning of the file is missing.
After messing around and trying to figure out what was going on, I found out that some of the starting chunks of the request to download the update file, were not being parsed through DigestTransform via configurePipes in /packages/electron-builder-http/src/httpExecutor, because ensureDirPromise has not yet completed in /packages/electron-auto-updater/src/electronHttpExecutor.ts#L74.
This may not have shown as an issue for those using other publish providers, where creating a directory is faster than receiving the first chunks of the request, but in my case, the server is very close (and will be for users using my application), even though I have an SSD, the network request was still faster.
My local fix was to create the directory first before net.request is called, which caused the downloads to no longer be corrupted. maybe another way is to pause the stream until after the directory is made?
edit at: /packages/electron-auto-updater/src/electronHttpExecutor.ts#L53
ensureDirPromise.then(()=>{constrequest=net.request(requestOpts,(response: Electron.IncomingMessage)=>{if(response.statusCode>=400){callback(newError(`Cannot download "${url}", status ${response.statusCode}: ${response.statusMessage}`))return}constredirectUrl=safeGetHeader(response,"location")if(redirectUrl!=null){if(redirectCount<maxRedirects){this.doDownload(redirectUrl,destination,redirectCount++,options,callback)}else{callback(newError(`Too many redirects (> ${maxRedirects})`))}return}if(!checkSha2(safeGetHeader(response,"X-Checksum-Sha2"),options.sha2,callback)){return}configurePipes(options,response,destination,callback)})this.addTimeOutHandler(request,callback)request.on("error",callback)request.end()}).catch(callback)
The text was updated successfully, but these errors were encountered:
Module Versions:
electron-builder@10.16.0
electron-builder-http@10.16.0
electron-auto-updater@0.9.0
Building For: electron@1.4.13 (windows 10 x64)
Hi, I have electron-auto-updater setup to download from a generic server.
I have been having issues of getting an error: "Error: SHA2 checksum mismatch, expected xxx, got xyx" (different hashes each time I build different setup files).
I had a look at the downloaded files, and noticed that some parts at the beginning of the file is missing.
After messing around and trying to figure out what was going on, I found out that some of the starting chunks of the request to download the update file, were not being parsed through DigestTransform via configurePipes in /packages/electron-builder-http/src/httpExecutor, because ensureDirPromise has not yet completed in /packages/electron-auto-updater/src/electronHttpExecutor.ts#L74.
This may not have shown as an issue for those using other publish providers, where creating a directory is faster than receiving the first chunks of the request, but in my case, the server is very close (and will be for users using my application), even though I have an SSD, the network request was still faster.
My local fix was to create the directory first before net.request is called, which caused the downloads to no longer be corrupted. maybe another way is to pause the stream until after the directory is made?
edit at: /packages/electron-auto-updater/src/electronHttpExecutor.ts#L53
The text was updated successfully, but these errors were encountered: