Skip to content

Commit

Permalink
Fix for problem when wrong plugin installation never ends (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomamo authored Jan 26, 2025
1 parent 2eb956e commit 2491646
Showing 1 changed file with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ const unpackExtensionInjectable = getInjectable({
const showInfoNotification = di.inject(showInfoNotificationInjectable);
const showErrorNotification = di.inject(showErrorNotificationInjectable);

const displayErrorMessage = (message: string, displayName: string) => {
showErrorNotification((
<p>
{"Installing extension "}
<b>{displayName}</b>
{" has failed: "}
<em>{message}</em>
</p>
));
};

return async (request, disposeDownloading) => {
const {
id,
Expand Down Expand Up @@ -72,33 +83,34 @@ 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((
<p>
{"Extension "}
<b>{displayName}</b>
{" successfully installed!"}
</p>
));
await when(() => extensionLoader.userExtensions.get().has(id), { timeout: 10000 })
.then(() => {
// Enable installed extensions by default.
extensionLoader.setIsEnabled(id, true);

showInfoNotification((
<p>
{"Extension "}
<b>{displayName}</b>
{" successfully installed!"}
</p>
));
})
.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);

logger.info(
`[EXTENSION-INSTALLATION]: installing ${request.fileName} has failed: ${message}`,
{ error },
);
showErrorNotification((
<p>
{"Installing extension "}
<b>{displayName}</b>
{" has failed: "}
<em>{message}</em>
</p>
));
displayErrorMessage(message, displayName);
} finally {
// Remove install state once finished
extensionInstallationStateStore.clearInstalling(id);
Expand Down

0 comments on commit 2491646

Please sign in to comment.