handle plugin load error

This commit is contained in:
Jan Prochazka
2021-04-29 07:38:44 +02:00
parent d171d7d785
commit 00d0c27502
3 changed files with 19 additions and 13 deletions

View File

@@ -64,6 +64,7 @@ module.exports = {
const res = []; const res = [];
for (const packageName of _.union(files1, files2)) { for (const packageName of _.union(files1, files2)) {
if (!/^dbgate-plugin-.*$/.test(packageName)) continue; if (!/^dbgate-plugin-.*$/.test(packageName)) continue;
try {
const isPackaged = files1.includes(packageName); const isPackaged = files1.includes(packageName);
const manifest = await fs const manifest = await fs
.readFile(path.join(isPackaged ? packagedPluginsDir() : pluginsdir(), packageName, 'package.json'), { .readFile(path.join(isPackaged ? packagedPluginsDir() : pluginsdir(), packageName, 'package.json'), {
@@ -77,6 +78,9 @@ module.exports = {
} }
manifest.isPackaged = isPackaged; manifest.isPackaged = isPackaged;
res.push(manifest); res.push(manifest);
} catch (err) {
console.log(`Skipped plugin ${packageName}, error:`, err.message);
}
} }
return res; return res;
}, },

View File

@@ -17,7 +17,7 @@
} }
</script> </script>
{#each plugins as packageManifest (packageManifest.name)} {#each plugins || [] as packageManifest (packageManifest.name)}
<div class="wrapper" on:click={() => openPlugin(packageManifest)}> <div class="wrapper" on:click={() => openPlugin(packageManifest)}>
<img class="icon" src={extractPluginIcon(packageManifest)} /> <img class="icon" src={extractPluginIcon(packageManifest)} />
<div class="ml-2"> <div class="ml-2">

View File

@@ -13,6 +13,8 @@
console.log('CRASH DETECTED!!!'); console.log('CRASH DETECTED!!!');
const lastDbGateCrashJson = localStorage.getItem('lastDbGateCrash'); const lastDbGateCrashJson = localStorage.getItem('lastDbGateCrash');
const lastDbGateCrash = lastDbGateCrashJson ? JSON.parse(lastDbGateCrashJson) : null; const lastDbGateCrash = lastDbGateCrashJson ? JSON.parse(lastDbGateCrashJson) : null;
// let detail = e?.reason?.stack || '';
// if (detail) detail = '\n\n' + detail;
if (lastDbGateCrash && new Date().getTime() - lastDbGateCrash < 30 * 1000) { if (lastDbGateCrash && new Date().getTime() - lastDbGateCrash < 30 * 1000) {
if ( if (