updater: tolerate read-only module dirs (fixes flatpak boot) - #251
Open
evandrodevbr wants to merge 1 commit into
Open
updater: tolerate read-only module dirs (fixes flatpak boot)#251evandrodevbr wants to merge 1 commit into
evandrodevbr wants to merge 1 commit into
Conversation
moduleUpdater.init() unconditionally purged and created the pending download directory, throwing EROFS/ENOENT on read-only filesystems (e.g. Flatpak, where localModulesRoot points at /app). Since the exception escaped startUpdate()'s promise chain in bootstrap.js, the entire app failed to boot: no window, no renderer. - guard the pending-dir setup in init() and log instead of throwing - guard createWriteStream errors in downloadModule() (previously uncaught exceptions when the pending dir cannot be created) - guard commitManifest() against read-only manifest paths - wrap moduleUpdater.init() in bootstrap.js so an updater failure can never take down the app bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #244
The problem
On Flatpak, Discord runs with
localModulesRootpointing at/app/discord/modules— a read-only directory inside the sandbox.moduleUpdater.init()creates thependingdirectory unconditionally, even whenSKIP_MODULE_UPDATEis active (which it is here, since the modules are local):This throws
EROFS/ENOENT— and sinceinit()is called fromstartUpdate(), which runs underapp.whenReady().then(startUpdate)with no try/catch at all, the exception aborts the whole startup. Practically speaking: the Discord process starts and stays alive, but no window is ever created — no splash, no renderer. Just an orphan process burning memory.Observed log (Discord 1.0.152 flatpak, Arch Linux):
After fixing the boot crash, the optional module downloads (krisp, game_utils, rpc) also surfaced
uncaughtExceptions —createWriteStreamhad no error handler and tried to write into the same read-only directory.The fix
Four small, conservative changes:
moduleUpdater.init()— the pending-directory purge/creation is now wrapped in try/catch and only logged. The directory is only useful when modules will be downloaded; on read-only filesystems it is useless anyway.downloadModule()—createWriteStreamnow has an error handler: instead of anuncaughtException, the failure is logged and the download tracking is finalized properly (with awriteFailedguard to avoid double-counting).commitManifest()— manifest write guarded against read-only paths.bootstrap.js— defense in depth:moduleUpdater.init()wrapped in try/catch. An updater failure should never be able to take down the whole app bootstrap.Testing
Validated on Flatpak (Arch Linux, Discord 1.0.152 + Vencord): Discord boots normally, window created, renderer alive:
The former download
uncaughtExceptions became clean logs:On writable systems the behavior is unchanged: the
pendingdirectory is still created normally and downloads work as before.