From 1e23571e830e5c152429f553e07bca493045a6c5 Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Wed, 6 Dec 2023 22:58:11 +0100 Subject: [PATCH] fix: trying to start a plugin, errors for dependencies were not reported --- src/plugins.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins.ts b/src/plugins.ts index 4a9195c5a..22d585044 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -351,8 +351,8 @@ function watchPlugin(id: string, path: string) { starting = pendingPromise() // if dependencies are not ready right now, we give some time. Not super-solid but good enough for now. const info = await parsePlugin() - if (!await waitFor(async () => _.isEmpty(await getMissingDependencies(info)), { timeout: 5_000 })) - return console.debug("plugin missing dependencies", id) + if (!await waitFor(() => _.isEmpty(getMissingDependencies(info)), { timeout: 5_000 })) + throw Error("plugin missing dependencies: " + _.map(getMissingDependencies(info), x => x.repo).join(', ')) if (getPluginInfo(id)) setError(id, '') const alreadyRunning = plugins[id] @@ -424,7 +424,9 @@ function getError(id: string) { } function setError(id: string, error: string) { - getPluginInfo(id).error = error + const info = getPluginInfo(id) + if (!info) return + info.error = error events.emit('pluginUpdated', { id, error }) } @@ -476,7 +478,7 @@ function calculateBadApi(data: AvailablePlugin) { : undefined } -export async function getMissingDependencies(plugin: CommonPluginInterface) { +export function getMissingDependencies(plugin: CommonPluginInterface) { return onlyTruthy((plugin?.depend || []).map((dep: any) => { const res = findPluginByRepo(dep.repo) const error = !res ? 'missing'