diff --git a/common/changes/@microsoft/rush/sennyeya-fix-pnpm-sync_2025-07-18-17-47.json b/common/changes/@microsoft/rush/sennyeya-fix-pnpm-sync_2025-07-18-17-47.json new file mode 100644 index 00000000000..d59e2c90cad --- /dev/null +++ b/common/changes/@microsoft/rush/sennyeya-fix-pnpm-sync_2025-07-18-17-47.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Do not run afterExecuteOperation if the operation has not actually completed.", + "type": "none", + "packageName": "@microsoft/rush" + } + ], + "packageName": "@microsoft/rush", + "email": "aramissennyeydd@users.noreply.github.com" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts b/libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts index 7908a106e91..01cc0845889 100644 --- a/libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts +++ b/libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts @@ -263,14 +263,19 @@ export class OperationExecutionManager { const onOperationCompleteAsync: (record: OperationExecutionRecord) => Promise = async ( record: OperationExecutionRecord ) => { - try { - await this._afterExecuteOperation?.(record); - } catch (e) { - this._reportOperationErrorIfAny(record); - record.error = e; - record.status = OperationStatus.Failure; + // If the operation is not terminal, we should _only_ notify the queue to assign operations. + if (!record.isTerminal) { + this._executionQueue.assignOperations(); + } else { + try { + await this._afterExecuteOperation?.(record); + } catch (e) { + this._reportOperationErrorIfAny(record); + record.error = e; + record.status = OperationStatus.Failure; + } + this._onOperationComplete(record); } - this._onOperationComplete(record); }; const onOperationStartAsync: ( @@ -296,8 +301,8 @@ export class OperationExecutionManager { const status: OperationStatus = this._hasAnyFailures ? OperationStatus.Failure : this._hasAnyNonAllowedWarnings - ? OperationStatus.SuccessWithWarning - : OperationStatus.Success; + ? OperationStatus.SuccessWithWarning + : OperationStatus.Success; return { operationResults: this._executionRecords, @@ -431,13 +436,12 @@ export class OperationExecutionManager { this._hasAnyNonAllowedWarnings = this._hasAnyNonAllowedWarnings || !runner.warningsAreAllowed; break; } - } - if (record.isTerminal) { - // If the operation was not remote, then we can notify queue that it is complete - this._executionQueue.complete(record); - } else { - this._executionQueue.assignOperations(); + default: { + throw new InternalError(`Unexpected operation status: ${status}`); + } } + + this._executionQueue.complete(record); } }