From 2491646a50d85421981e61647bd34ab8f1af864e Mon Sep 17 00:00:00 2001 From: Mario Offertucci <45656028+mariomamo@users.noreply.github.com> Date: Sun, 26 Jan 2025 20:05:22 +0100 Subject: [PATCH] Fix for problem when wrong plugin installation never ends (#102) --- .../unpack-extension.injectable.tsx | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/core/src/renderer/components/extensions/attempt-install/unpack-extension.injectable.tsx b/packages/core/src/renderer/components/extensions/attempt-install/unpack-extension.injectable.tsx index 0e8ad263..ceda683f 100644 --- a/packages/core/src/renderer/components/extensions/attempt-install/unpack-extension.injectable.tsx +++ b/packages/core/src/renderer/components/extensions/attempt-install/unpack-extension.injectable.tsx @@ -32,6 +32,17 @@ const unpackExtensionInjectable = getInjectable({ const showInfoNotification = di.inject(showInfoNotificationInjectable); const showErrorNotification = di.inject(showErrorNotificationInjectable); + const displayErrorMessage = (message: string, displayName: string) => { + showErrorNotification(( +
+ {"Installing extension "} + {displayName} + {" has failed: "} + {message} +
+ )); + }; + return async (request, disposeDownloading) => { const { id, @@ -72,18 +83,26 @@ const unpackExtensionInjectable = getInjectable({ await fse.move(unpackedRootFolder, extensionFolder, { overwrite: true }); // wait for the loader has actually install it - await when(() => extensionLoader.userExtensions.get().has(id)); - - // Enable installed extensions by default. - extensionLoader.setIsEnabled(id, true); - - showInfoNotification(( -- {"Extension "} - {displayName} - {" successfully installed!"} -
- )); + await when(() => extensionLoader.userExtensions.get().has(id), { timeout: 10000 }) + .then(() => { + // Enable installed extensions by default. + extensionLoader.setIsEnabled(id, true); + + showInfoNotification(( ++ {"Extension "} + {displayName} + {" successfully installed!"} +
+ )); + }) + .catch(error => { + // There was an error during plugin installation + logger.info( + `[EXTENSION-INSTALLATION]: installing ${request.fileName} has failed due a timeout`, + { error }); + displayErrorMessage("There was an error during the installation", displayName); + }); } catch (error) { const message = getMessageFromError(error); @@ -91,14 +110,7 @@ const unpackExtensionInjectable = getInjectable({ `[EXTENSION-INSTALLATION]: installing ${request.fileName} has failed: ${message}`, { error }, ); - showErrorNotification(( -- {"Installing extension "} - {displayName} - {" has failed: "} - {message} -
- )); + displayErrorMessage(message, displayName); } finally { // Remove install state once finished extensionInstallationStateStore.clearInstalling(id);