From 3f41cf157453890726f1aba17d55260a3a22466c Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Thu, 16 Oct 2025 11:45:05 -0400 Subject: [PATCH] fix(plugins): refine error and success handling during plugin installation - Updated the `UnraidPluginsService` to ensure that error and success handling for plugin installations only occurs when the operation status is RUNNING. - Added checks in the `handleFailure` and `handleSuccess` methods to prevent state changes if the operation is not in progress. - This change improves the reliability of the plugin installation process by preventing unintended state updates after the operation has completed or failed. --- .../unraid-plugins/unraid-plugins.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.ts b/api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.ts index bc2448465..dc9896652 100644 --- a/api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.ts +++ b/api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.ts @@ -83,10 +83,16 @@ export class UnraidPluginsService { } child.on('error', (error) => { - this.handleFailure(operation, error); + if (operation.status === PluginInstallStatus.RUNNING) { + this.handleFailure(operation, error); + } }); child.on('close', (code) => { + if (operation.status !== PluginInstallStatus.RUNNING) { + return; + } + if (code === 0) { this.handleSuccess(operation); } else { @@ -150,6 +156,10 @@ export class UnraidPluginsService { } private handleSuccess(operation: OperationState) { + if (operation.status !== PluginInstallStatus.RUNNING) { + return; + } + const timestamp = new Date(); operation.status = PluginInstallStatus.SUCCEEDED; operation.finishedAt = timestamp; @@ -168,6 +178,10 @@ export class UnraidPluginsService { } private handleFailure(operation: OperationState, error: unknown) { + if (operation.status !== PluginInstallStatus.RUNNING) { + return; + } + const timestamp = new Date(); operation.status = PluginInstallStatus.FAILED; operation.finishedAt = timestamp;