fix(desktop): resolve app icon from asar.unpacked so the app can launch - #423
Merged
Merged
Conversation
The packaged macOS app died at startup with an uncaught main-process
exception and never opened a window:
A JavaScript error occurred in the main process, Uncaught Exception:
Error: Failed to load image from path
'/Applications/Hermes.app/Contents/Resources/app.asar/public/apple-touch-icon.png'
at createWindow (.../electron-main.mjs)
getAppIconPath() returns the first APP_ICON_PATHS candidate that
fs.statSync() finds. Electron shims fs so it CAN read inside app.asar,
but app.dock.setIcon() is a native call that CANNOT — so the in-asar
'public/' candidate was selected and then threw, aborting createWindow().
Order the asar.unpacked candidate first (dist/** is in build.asarUnpack,
so it resolves to a real on-disk file in a packaged app) and keep the
in-asar paths as dev-run fallbacks, where APP_ROOT has no .asar segment.
Also wrap the setIcon() call in try/catch: a cosmetic dock icon must
never be able to take down the window.
Adds electron/app-icon-path.test.ts locking both contracts plus the
build.asarUnpack precondition the unpacked candidate depends on.
RED-proven: the ordering test fails against the previous ordering.
Collaborator
Author
FleetReviewConfidence: 3/5 Findings
FleetReview provenance · models: B=gpt-5.6-sol, C=claude-code-opus-4-8, F=gpt-5.6-sol, G=grok-4.5 · cost: $2.40 · duration: 10m 01s · rounds: 1 · files examined: 2 |
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.
The symptom
The packaged macOS app died at startup with an uncaught main-process exception and never opened a window:
Found during the 2026-07-23 parity deploy by taking a screenshot of the freshly-installed app. Every other signal was green — install-stamp SHA matched the pin, 730 desktop tests passed, all build gates OK — because the crash only happens in a packaged build.
Root cause
getAppIconPath()returns the firstAPP_ICON_PATHScandidate thatfs.statSync()finds. There is a real asymmetry between the two readers:fs.statSync()can read paths insideapp.asar(Electron shimsfs), so the in-asarpublic/candidate passes the existence check.app.dock.setIcon()is a native call that cannot read inside an asar, so the same path throws.The in-asar candidate was ordered first, got selected, and then threw — aborting
createWindow()and leaving the app with no window at all.The fix
asar.unpackedcandidate first.dist/**is inbuild.asarUnpack, so it resolves to a real on-disk file in a packaged app. The in-asar paths remain as fallbacks for dev runs, whereAPP_ROOThas no.asarsegment.setIcon()in try/catch. A cosmetic dock icon must never be able to take down the window — defense in depth for any future unreadable-path case.Tests
New
electron/app-icon-path.test.tslocks three contracts:unpackedPathFor()candidate is ordered first,setIcon()call is guarded,build.asarUnpackstill unpacksdist/(the precondition the unpacked candidate depends on).RED-proven: reverting the ordering makes the first test fail with the explanatory message; restoring it passes. 3/3 green.
Verification
Rebuilt and installed on the Mac Studio at this SHA, launched the app, and confirmed a working window: session list, chat transcript, channel counts, "Gateway ready". No error dialog.