fix: handle missing notification settings app on Linux#8304
Open
mvanhorn wants to merge 1 commit intoblock:mainfrom
Open
fix: handle missing notification settings app on Linux#8304mvanhorn wants to merge 1 commit intoblock:mainfrom
mvanhorn wants to merge 1 commit intoblock:mainfrom
Conversation
Replace spawn() try/catch with canSpawn() check using
execFileSync('which', [cmd]). Node.js spawn() emits ENOENT
asynchronously via the error event, so try/catch never catches
it. canSpawn() detects missing binaries before spawning.
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.
Summary
Fixes a crash when clicking "Open Settings" in Settings > App > Notifications on Linux desktops that don't have GNOME, KDE, or XFCE installed.
Changes
In
ui/desktop/src/main.ts, theopen-notifications-settingsIPC handler usedspawn()insidetry/catchblocks for each desktop environment. Node.jsspawn()does not throw synchronously on ENOENT; it emits the error asynchronously via the ChildProcess 'error' event. Thetry/catchblocks never fired, so the app crashed withspawn gnome-control-center ENOENT.Fix: added a
canSpawn(cmd)helper that usesexecFileSync('which', [cmd])to check if the binary exists before callingspawn(). Each DE check now usesif (canSpawn(...))instead oftry { spawn(...) } catch. When no settings app is found, returnsfalseinstead of crashing.Testing
Verified the logic by reading the Node.js
child_processdocs confirmingspawn()ENOENT behavior. The fix is a straightforward control flow change with no new dependencies.Fixes #8292
This contribution was developed with AI assistance (Codex).