Skip to content

The agent that grows with you

fix(desktop): resolve the app icon from the unpacked dist before any in-archive path

John Paul Solivaee6852c8addb
diff --git a/apps/desktop/electron/app-icon.test.ts b/apps/desktop/electron/app-icon.test.ts
index 1be8c572d52..ffe0a81b439 100644
--- a/apps/desktop/electron/app-icon.test.ts
+++ b/apps/desktop/electron/app-icon.test.ts
@@ -52,6 +52,28 @@ test('decodingFileProbe rejects a directory', () => {
}
})
+// #96857: on a packaged build every path inside app.asar is stat'ed through Electron's asar
+// fs.Stats shim, which emits Node's DEP0180 ("fs.Stats constructor is deprecated") on every launch.
+// dist/** is asarUnpack'ed, so the real on-disk copy must be tried before any in-archive rung;
+// resolveAppIcon stops at the first decodable candidate and never reaches the archive.
+test('the unpacked on-disk icon precedes every in-archive PNG rung', () => {
+ for (const isWindows of [false, true]) {
+ const appRoot = path.join('/opt/Hermes/resources', 'app.asar')
+
+ const candidates = appIconCandidates({
+ isWindows,
+ appRoot,
+ resourcesPath: '/opt/Hermes/resources',
+ unpackedPathFor: p => p.replace(/app\.asar(?=$|[\\/])/, 'app.asar.unpacked')
+ })
+
+ const pngs = candidates.filter(c => c.endsWith('.png'))
+ const firstInArchive = pngs.findIndex(c => c.startsWith(appRoot + path.sep))
+ const unpacked = pngs.findIndex(c => c.includes('app.asar.unpacked'))
+ assert.ok(unpacked !== -1 && unpacked < firstInArchive, `unpacked first (isWindows=${isWindows}): ${pngs.join(', ')}`)
+ }
+})
+
test('appIconCandidates keeps the documented precedence ladder', () => {
const mac = appIconCandidates({
isWindows: false,
@@ -60,9 +82,9 @@ test('appIconCandidates keeps the documented precedence ladder', () => {
})
assert.deepEqual(mac, [
+ path.join('/Applications/Hermes.app/Contents/Resources.unpacked', 'dist', 'apple-touch-icon.png'),
path.join('/Applications/Hermes.app/Contents/Resources', 'public', 'apple-touch-icon.png'),
- path.join('/Applications/Hermes.app/Contents/Resources', 'dist', 'apple-touch-icon.png'),
- path.join('/Applications/Hermes.app/Contents/Resources.unpacked', 'dist', 'apple-touch-icon.png')
+ path.join('/Applications/Hermes.app/Contents/Resources', 'dist', 'apple-touch-icon.png')
])
// Windows prepends the two full-bleed .ico rungs ahead of the PNG ladder.
diff --git a/apps/desktop/electron/app-icon.ts b/apps/desktop/electron/app-icon.ts
index 975638a32a6..52ad24f197b 100644
--- a/apps/desktop/electron/app-icon.ts
+++ b/apps/desktop/electron/app-icon.ts
@@ -78,8 +78,11 @@ export function appIconCandidates(opts: {
return [
...(isWindows ? [path.join(resourcesPath ?? '', 'icon.ico'), path.join(appRoot, 'assets', 'icon.ico')] : []),
+ // The unpacked on-disk copy first (dist/** is asarUnpack'ed), as resolveWebDist() does: statting
+ // any path inside app.asar goes through Electron's asar fs.Stats shim, which emits Node's DEP0180
+ // on every packaged launch (#96857). In a dev tree unpackedPathFor is the identity.
+ path.join(unpackedPathFor(appRoot), 'dist', 'apple-touch-icon.png'),
path.join(appRoot, 'public', 'apple-touch-icon.png'),
- path.join(appRoot, 'dist', 'apple-touch-icon.png'),
- path.join(unpackedPathFor(appRoot), 'dist', 'apple-touch-icon.png')
+ path.join(appRoot, 'dist', 'apple-touch-icon.png')
]
}