Skip to content

Commit 93d5baf

Browse files
committed
fix(plugins): improve error handling during plugin loading and reset watchers on failure
Signed-off-by: 7HR4IZ3 <90985774+7HR4IZ3@users.noreply.github.com>
1 parent c730541 commit 93d5baf

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/lib/acode.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,10 @@ export default class Acode {
429429
}
430430

431431
[onPluginsLoadCompleteCallback]() {
432-
for (const key in this.#pluginWatchers) {
433-
this.#pluginWatchers[key].reject(new Error(`Plugin '${key}' failed to load.`));
432+
for (const pluginId in this.#pluginWatchers) {
433+
this.#pluginWatchers[pluginId].reject(
434+
new Error(`Plugin '${pluginId}' failed to load.`),
435+
);
434436
}
435437
this.#pluginWatchers = {};
436438
}

src/lib/loadPlugins.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,12 @@ export default async function loadPlugins(loadOnlyTheme = false) {
105105
BROKEN_PLUGINS.delete(pluginId);
106106
}
107107
} catch (error) {
108-
console.error(`Error loading plugin ${pluginId}:`, error);
108+
console.error(`Error loading plugin ${pluginId}:`, error);git
109109
// mark plugin as broken to avoid repeated attempts until user intervenes
110-
try {
111-
BROKEN_PLUGINS.set(pluginId, {
112-
error: String(error.message || error),
113-
timestamp: Date.now(),
114-
});
115-
} catch (e) {
116-
console.warn("Failed to mark plugin as broken:", e);
117-
}
110+
BROKEN_PLUGINS.set(pluginId, {
111+
error: String(error.message || error),
112+
timestamp: Date.now(),
113+
});
118114
failedPlugins.push(pluginId);
119115
results.push(false);
120116
}

0 commit comments

Comments
 (0)