fix: trying to start a plugin, errors for dependencies were not reported
Massimo Melina committed
Dec 6, 2023 at 22:58 UTC
1e23571e830e5c152429f553e07bca493045a6c5
1 file changed
+6
-4
src/plugins.ts
+6
-4
@@ -351,8 +351,8 @@ function watchPlugin(id: string, path: string) {
351
starting = pendingPromise()
352
// if dependencies are not ready right now, we give some time. Not super-solid but good enough for now.
353
const info = await parsePlugin()
354
- if (!await waitFor(async () => _.isEmpty(await getMissingDependencies(info)), { timeout: 5_000 }))
355
- return console.debug("plugin missing dependencies", id)
354
+ if (!await waitFor(() => _.isEmpty(getMissingDependencies(info)), { timeout: 5_000 }))
355
+ throw Error("plugin missing dependencies: " + _.map(getMissingDependencies(info), x => x.repo).join(', '))
356
if (getPluginInfo(id))
357
setError(id, '')
358
const alreadyRunning = plugins[id]
@@ -424,7 +424,9 @@ function getError(id: string) {
424
}
425
426
function setError(id: string, error: string) {
427
- getPluginInfo(id).error = error
427
+ const info = getPluginInfo(id)
428
+ if (!info) return
429
+ info.error = error
430
events.emit('pluginUpdated', { id, error })
431
}
432
@@ -476,7 +478,7 @@ function calculateBadApi(data: AvailablePlugin) {
478
: undefined
479
}
480
479
-export async function getMissingDependencies(plugin: CommonPluginInterface) {
481
+export function getMissingDependencies(plugin: CommonPluginInterface) {
482
return onlyTruthy((plugin?.depend || []).map((dep: any) => {
483
const res = findPluginByRepo(dep.repo)
484
const error = !res ? 'missing'