From e56a62c5390958e585f299751bafd13becc1c9b6 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Mon, 23 Dec 2024 09:48:28 -0500 Subject: [PATCH] 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. --- src/backend/src/services/AppIconService.js | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/backend/src/services/AppIconService.js b/src/backend/src/services/AppIconService.js index 25030a0616..1830b867e9 100644 --- a/src/backend/src/services/AppIconService.js +++ b/src/backend/src/services/AppIconService.js @@ -84,7 +84,8 @@ class AppIconService extends BaseService { const dir_app_icons = await this.get_app_icons(); console.log('APP UID', app_uid); const node = await dir_app_icons.getChild(`${app_uid}-${size}.png`); - if ( ! await node.exists() ) { + + const get_fallback_icon = async () => { // Use database-stored icon as a fallback app_icon = app_icon ?? await (async () => { const app = await get_app({ uid: app_uid }); @@ -100,15 +101,26 @@ class AppIconService extends BaseService { }; } - const svc_su = this.services.get('su'); - const ll_read = new LLRead(); - return { - mime: 'image/png', - stream: await ll_read.run({ - fsNode: node, - actor: await svc_su.get_system_actor(), - }) - }; + if ( ! await node.exists() ) { + return await get_fallback_icon(); + } + + try { + const svc_su = this.services.get('su'); + const ll_read = new LLRead(); + return { + mime: 'image/png', + stream: await ll_read.run({ + fsNode: node, + actor: await svc_su.get_system_actor(), + }) + }; + } catch (e) { + this.errors.report('AppIconService.get_icon_stream', { + source: e, + }); + return await get_fallback_icon(); + } } /**