electron-builder
electron-builder copied to clipboard
Auto Updater EPERM Issues
- Electron-Builder Version: 24.6.4
- Node Version: 18.15.0
- Electron Version: 25.3.0
- Electron Type (current, beta, nightly): current
- Target: Windows, macOS, Linux
We have Sentry enabled throughout our Application and have noticed a considerable amount of errors with the Auto Updater in regards to some update files operations not being permitted.
We do not modify any of the core functionality of the updater and use it mostly out of the box with a few additions around when quitAndInstall()
is called ensuring that we don't update when in the dock.
Happy to provide any additional context if needed.
Are you distributing both portable
and nsis
targets? Can you please post your electron-builder config?
@mmaietta I had the same issue, my sentry log is like that:
Electron-Builder Version: 23.6.0
Node Version: 16.17.1
Electron Version: 19.0.0
Electron Type (current, beta, nightly): current
Target: Windows, macOS
all of this error happened on Windows
my packaging config is blow:
"nsis": {
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"shortcutName": OKKI${ENV_NAME}
,
"include": "./scripts/installer.nsh",
"differentialPackage": false,
"packElevateHelper": true,
"guid": OKKI${ENV_NAME}
},
"win": {
"target": [
{
"target": "nsis",
"arch": [
"ia32",
"x64"
]
}
],
"signingHashAlgorithms":['sha1', 'sha256'],
"sign": "./scripts/signWin.js",
"verifyUpdateCodeSignature": false,
"signDlls": true,
"timeStampServer": "http://timestamp.digicert.com"
},
Are you distributing both
portable
andnsis
targets? Can you please post your electron-builder config?
Here is the builder-effective-config.yaml
directories:
output: release
buildResources: build
generateUpdatesFilesForAllChannels: true
appId: com.moonsworth.client
extraMetadata:
version: 3.1.0
productName: Lunar Client
files:
- filter:
- build/**/*
- dist/**/*
- dist-electron/**/*
- '!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}'
- '!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}'
- '!**/node_modules/*.d.ts'
- '!**/node_modules/.bin'
- '!**/*.{iml,o,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}'
- '!.editorconfig'
- '!**/._*'
- '!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,.gitignore,.gitattributes}'
- '!**/{__pycache__,thumbs.db,.flowconfig,.idea,.vs,.nyc_output}'
- '!**/{appveyor.yml,.travis.yml,circle.yml}'
- '!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}'
- '!**/node_modules/typescript/**/*'
- '!**/node_modules/register-scheme/**/*'
protocols:
- name: lunarclient
schemes:
- lunarclient
win:
target: nsis-web
icon: build/icon.png
signingHashAlgorithms:
- sha256
sign: ./winSign.js
mac:
category: public.app-category.games
hardenedRuntime: true
artifactName: ${productName} v${version}.${ext}
entitlements: build/entitlements.plist
entitlementsInherit: build/entitlements.plist
target:
- dmg
- zip
icon: build/icon-macos.png
notarize: {}
linux:
target: AppImage
dmg:
title: Lunar Client
writeUpdateInfo: false
window:
width: 1000
height: 776
iconSize: 120
contents:
- x: 296
'y': 496
- x: 704
'y': 496
type: link
name: Applications
path: /Applications
nsisWeb:
oneClick: true
perMachine: false
license: build/license_en.txt
artifactName: ${productName} v${version}.${ext}
installerIcon: build/icon-installer.ico
uninstallerIcon: build/icon-uninstaller.ico
installerHeaderIcon: build/icon.ico
uninstallDisplayName: Uninstall ${productName}
installerSidebar: build/sidebar.bmp
uninstallerSidebar: build/sidebar.bmp
differentialPackage: false
publish:
- provider: generic
url: https://launcherupdates.lunarclientcdn.com
publishAutoUpdate: true
useMultipleRangeRequest: false
electronVersion: 25.3.0
@mmaietta do you need any more information?
Idk tbh. I was hoping it was due to portable
being used as I recall there being a caveat with it. Since it's nsis-web
, I have no idea what could be causing it. I personally am not able to debug it any further on my arm64 mac though. Will need community members to debug it and propose a solution.
electron-builder currently detects some error responses, but it's not inclusive of EPERM
.
https://github.com/electron-userland/electron-builder/blob/4c9b8296b9104a28ad9bccf643eec3d6c0dff6ab/packages/electron-updater/src/NsisUpdater.ts#L162-L170
Not sure how to handle EPERM
on Windows.
For AppImage updates, we just use chmod
https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppImageUpdater.ts#L71
Any ideas on how we can attend to EPERM
issues?
Idk tbh. I was hoping it was due to
portable
being used as I recall there being a caveat with it. Since it'snsis-web
, I have no idea what could be causing it. I personally am not able to debug it any further on my arm64 mac though. Will need community members to debug it and propose a solution. electron-builder currently detects some error responses, but it's not inclusive ofEPERM
.https://github.com/electron-userland/electron-builder/blob/4c9b8296b9104a28ad9bccf643eec3d6c0dff6ab/packages/electron-updater/src/NsisUpdater.ts#L162-L170
Not sure how to handle
EPERM
on Windows. For AppImage updates, we just usechmod
https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppImageUpdater.ts#L71Any ideas on how we can attend to
EPERM
issues?
I did read in another issue that it may be potentially due to a race condition with checking the update twice, although we do have a locking mechanism within our application and were not able to reproduce: https://github.com/electron-userland/electron-builder/issues/5408#issuecomment-1705086586
Just wanted to bump this as we did another production deploy of our application today. We also see EBUSY errors aswell as per the screenshot:
Does anyone know if there is a way to detect via javascript whether a resource is no longer locked? I'm not familiar with EPERM
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not entirely sure but thought I would just mention that this is still an ongoing issue
Here is my resolution, I hope this can help you.
class Updater {
#downloading = false
#autoUpdater
#init() {
this.#autoUpdater = new NsisUpdater({
// config...
})
// disable auto download
this.#autoUpdater.autoDownload = false
this.#autoUpdater.on('update-avaliable' , async (info) => {
await this.downloadUpdate()
}
this.#autoUpdater.on('error', (info) => {
this.#downloading = false
}
this.#autoUpdater.on('update-downloaded', (info) => {
this.#downloading = false
}
}
async downloadUpdate() {
if (this.#downloading) {
return
}
this.#downloading = true
await this.#autoUpdater.downloadUpdate()
}
}
Is that a fix you've made in your code or in the electron-builder library?