Electron-builder: Retry of electron zip download fails with invalid zip file

Created on 15 Sep 2018  Â·  4Comments  Â·  Source: electron-userland/electron-builder


  • Version: 20.28.4

  • Target: Windows NSIS



Running electron-builder fails with log below. I have a theory as to why - I've tried downloading https://github.com/electron/electron/releases/download/v2.0.9/electron-v2.0.9-win32-x64.zip with Chrome and it is currently very slow, taking 10 minutes to download around 50MiB. I assume this is the case for electron-builder as well, and the download/retrying lines does take a while to go through. If I look in HOME/AppData/Local/electron/Cache I can see a 222MiB file (i.e. more than 4 times larger than the actual zip). I assume that electron-builder is timing out on the download or noticing the slow rate, and retrying, but not resuming the download correctly. I assume it is starting the download from byte 0 again, but appending to the existing file, either because it intended to resume the download from the correct byte but didn't, or intended to overwrite the existing file but didn't.

Rerunning doesn't help - the corrupt zip is reused and app-builder fails again (it seems like it should be deleted when it is found to be corrupt?).

I renamed the too-large file in the cache and replaced it with the file downloaded in Chrome and reran, and this works fine.

I've kept a copy of the large invalid zip file in case you want me to check that it really does contain multiple zip headers, I don't have a hex editor installed here to check myself (can't find a good one for Windows!).

PS C:\Users\trepi\Documents\GitHub\scalajs-react-electron> yarn dist
yarn run v1.9.4
$ electron-builder
  • electron-builder version=20.28.4
  • loaded configuration file=package.json ("build" field)
  • writing effective config file=dist\builder-effective-config.yaml
  • no native production dependencies
  • packaging       platform=win32 arch=x64 electron=2.0.9 appOutDir=dist\win-unpacked
  • downloading               parts=8 size=51 MB url=https://github.com/electron/electron/releases/download/v2.0.9/electron-v2.0.9-win32-x64.zip
  • retrying (1)
  • retrying (1)
  • retrying (1)
  • retrying (1)
  • retrying (1)
  • retrying (1)
  • retrying (1)
  • downloaded                duration=1m11.975s url=https://github.com/electron/electron/releases/download/v2.0.9/electron-v2.0.9-win32-x64.zip
  • cannot unpack electron zip file, will be re-downloaded error=zip: not a valid zip file
  ⨯ zip: not a valid zip file

Error: C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code 1
    at ChildProcess.childProcess.once.code (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\builder-util\src\util.ts:254:14)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
From previous event:
    at unpack (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\out\electron\ElectronFramework.js:191:18)
    at Object.prepareApplicationStageDirectory (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\electron\ElectronFramework.ts:148:50)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\platformPackager.ts:179:21
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.doPack (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\platformPackager.ts:166:165)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\platformPackager.ts:112:16
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.pack (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\platformPackager.ts:110:95)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:376:24
    at Generator.next (<anonymous>)
    at xfs.stat (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\fs-extra-p\node_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\graceful-fs\polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:153:5)
From previous event:
    at Packager.doBuild (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:344:39)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:314:57
    at Generator.next (<anonymous>)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\graceful-fs\graceful-fs.js:99:16
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\graceful-fs\graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
From previous event:
    at Packager._build (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:285:133)
    at C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:281:23
    at Generator.next (<anonymous>)
From previous event:
    at Packager.build (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\packager.ts:238:14)
    at build (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\app-builder-lib\src\index.ts:58:28)
    at build (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\electron-builder\src\builder.ts:227:10)
    at then (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\electron-builder\src\cli\cli.ts:42:48)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at Object.args [as handler] (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\electron-builder\src\cli\cli.ts:42:48)
    at Object.runCommand (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\yargs\lib\command.js:238:44)
    at Object.parseArgs [as _parseArgs] (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\yargs\yargs.js:1085:24)
    at Object.get [as argv] (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\yargs\yargs.js:1000:21)
    at Object.<anonymous> (C:\Users\trepi\Documents\GitHub\scalajs-react-electron\node_modules\electron-builder\src\cli\cli.ts:25:28)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
obsolete

Most helpful comment

Yes I'd also found that worked (using ~/AppData/Local/electron/Cache on Windows), I was thinking this was something that could be fixed in electron-builder (hopefully fairly easily).

All 4 comments

Hi @trepidacious,
It seems to be an ongoing problem. I had it yesterday as well.
I fixed it on my side downloading https://github.com/electron/electron/releases/download/v2.0.9/electron-v2.0.9-win32-x64.zip manually and moving the zip file to ~/Library/Cache/electron
Like this
image

Try it, it should be ok.

Yes I'd also found that worked (using ~/AppData/Local/electron/Cache on Windows), I was thinking this was something that could be fixed in electron-builder (hopefully fairly easily).

For those for which this fix didn't work (like me), check destination ~/Library/Caches/electron instead (with an s at the end of Caches). It was this path on my setup.

This XML file does not appear to have any style information associated with it. The document tree is shown below.

AccessDenied
Request has expired
300
2018-12-11T13:03:05Z
2018-12-11T13:04:55Z
80D3E5B6DE49BB19

oYicb6kjMCFVhKF+EPL6efeHwcf4vRzh0nsj7utfOaWtV5ZE3EFy3EXUvuxGJNhglzvJ8q3qc3c=

the session of the download has been expired !! that's why you see this error
just try to download the zips with explorer , it should work !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnWeisz picture JohnWeisz  Â·  3Comments

lbssousa picture lbssousa  Â·  3Comments

leo picture leo  Â·  3Comments

mstralka picture mstralka  Â·  3Comments

iklemm picture iklemm  Â·  3Comments