Skip to content

Commit e56a62c

Browse files
committed
fix: try catching icon read errors before stream
Current issue with get-launch-apps wasn't fixed by catching errors while reading the stream so this next attempt catches errors from the call to start reading. If the error occurs asynchronously this may not work either.
1 parent e736e42 commit e56a62c

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/backend/src/services/AppIconService.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class AppIconService extends BaseService {
8484
const dir_app_icons = await this.get_app_icons();
8585
console.log('APP UID', app_uid);
8686
const node = await dir_app_icons.getChild(`${app_uid}-${size}.png`);
87-
if ( ! await node.exists() ) {
87+
88+
const get_fallback_icon = async () => {
8889
// Use database-stored icon as a fallback
8990
app_icon = app_icon ?? await (async () => {
9091
const app = await get_app({ uid: app_uid });
@@ -100,15 +101,26 @@ class AppIconService extends BaseService {
100101
};
101102
}
102103

103-
const svc_su = this.services.get('su');
104-
const ll_read = new LLRead();
105-
return {
106-
mime: 'image/png',
107-
stream: await ll_read.run({
108-
fsNode: node,
109-
actor: await svc_su.get_system_actor(),
110-
})
111-
};
104+
if ( ! await node.exists() ) {
105+
return await get_fallback_icon();
106+
}
107+
108+
try {
109+
const svc_su = this.services.get('su');
110+
const ll_read = new LLRead();
111+
return {
112+
mime: 'image/png',
113+
stream: await ll_read.run({
114+
fsNode: node,
115+
actor: await svc_su.get_system_actor(),
116+
})
117+
};
118+
} catch (e) {
119+
this.errors.report('AppIconService.get_icon_stream', {
120+
source: e,
121+
});
122+
return await get_fallback_icon();
123+
}
112124
}
113125

114126
/**

0 commit comments

Comments
 (0)