From 33f13bdd114d78b2e5107e07be13a98b2d652cf8 Mon Sep 17 00:00:00 2001 From: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:26:44 +0530 Subject: [PATCH] fix(plugins): harden sidebar plugin loading and API checks --- src/sidebarApps/extensions/index.js | 40 ++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/sidebarApps/extensions/index.js b/src/sidebarApps/extensions/index.js index 83545cdcf..c2c36426d 100644 --- a/src/sidebarApps/extensions/index.js +++ b/src/sidebarApps/extensions/index.js @@ -218,7 +218,7 @@ async function searchPlugin() { $searchResult.onscroll = null; $searchResult.content = ""; - const status = helpers.checkAPIStatus(); + const status = await helpers.checkAPIStatus(); if (!status) { $searchResult.content = ( {strings.api_error} @@ -409,7 +409,7 @@ async function loadInstalled() { async function loadExplore() { if (this.collapsed) return; - const status = helpers.checkAPIStatus(); + const status = await helpers.checkAPIStatus(); if (!status) { $explore.$ul.content = {strings.api_error}; return; @@ -436,6 +436,7 @@ async function loadExplore() { currentPage++; updateHeight($explore); } catch (error) { + console.error("Failed to load plugins in sidebar explore:", error); $explore.$ul.content = {strings.error}; } finally { stopLoading($explore); @@ -446,15 +447,36 @@ async function listInstalledPlugins() { const plugins = await Promise.all( (await fsOperation(PLUGIN_DIR).lsDir()).map(async (item) => { const id = Url.basename(item.url); - const url = Url.join(item.url, "plugin.json"); - const plugin = await fsOperation(url).readFile("json"); - const iconUrl = getLocalRes(id, plugin.icon); - plugin.icon = await helpers.toInternalUri(iconUrl); - plugin.installed = true; - return plugin; + + try { + const url = Url.join(item.url, "plugin.json"); + const plugin = await fsOperation(url).readFile("json"); + + if (plugin.icon) { + const iconUrl = getLocalRes(id, plugin.icon); + try { + plugin.icon = await helpers.toInternalUri(iconUrl); + } catch (error) { + console.warn( + `Failed to resolve plugin icon for "${id}" in sidebar.`, + error, + ); + } + } + + plugin.installed = true; + return plugin; + } catch (error) { + console.warn( + `Skipping unreadable installed plugin "${id}" in sidebar.`, + error, + ); + return null; + } }), ); - return plugins; + + return plugins.filter(Boolean); } async function getFilteredPlugins(filterState) {