Skip to content

Commit cd27ac4

Browse files
committed
remove commitactions
1 parent 4f1f2b3 commit cd27ac4

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

packages/durabletask-js/src/worker/runtime-orchestration-context.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
2525
_isComplete: boolean;
2626
_result: any;
2727
_pendingActions: Record<number, pb.OrchestratorAction>;
28-
_commitActions: pb.OrchestratorAction[]; // Actions that should always be included (e.g., unlock messages)
2928
_pendingTasks: Record<number, CompletableTask<any>>;
3029
_sequenceNumber: any;
3130
_currentUtcDatetime: any;
@@ -46,7 +45,6 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
4645
this._isComplete = false;
4746
this._result = undefined;
4847
this._pendingActions = {};
49-
this._commitActions = [];
5048
this._pendingTasks = {};
5149
this._sequenceNumber = 0;
5250
this._currentUtcDatetime = new Date(1000, 0, 1);
@@ -154,7 +152,8 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
154152

155153
this._isComplete = true;
156154
this._completionStatus = status;
157-
this._pendingActions = {}; // Clear any pending actions
155+
// Note: We don't clear _pendingActions here because we need to send any pending actions
156+
// (e.g., entity unlock messages) along with the completion action.
158157

159158
this._result = result;
160159

@@ -176,7 +175,8 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
176175

177176
this._isComplete = true;
178177
this._completionStatus = pb.OrchestrationStatus.ORCHESTRATION_STATUS_FAILED;
179-
this._pendingActions = {}; // Cancel any pending actions
178+
// Note: We don't clear _pendingActions here because we need to send any pending actions
179+
// (e.g., entity unlock messages) along with the failure action.
180180

181181
const action = ph.newCompleteOrchestrationAction(
182182
this.nextSequenceNumber(),
@@ -193,7 +193,8 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
193193
}
194194

195195
this._isComplete = true;
196-
this._pendingActions = {}; // Clear any pending actions
196+
// Note: We don't clear _pendingActions here because we need to send any pending actions
197+
// (e.g., entity unlock messages) along with the continue-as-new action.
197198
this._completionStatus = pb.OrchestrationStatus.ORCHESTRATION_STATUS_CONTINUED_AS_NEW;
198199
this._newInput = newInput;
199200
this._saveEvents = saveEvents;
@@ -228,8 +229,7 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
228229
return [action];
229230
}
230231

231-
// Include both commit actions and pending actions
232-
return [...this._commitActions, ...Object.values(this._pendingActions)];
232+
return Object.values(this._pendingActions);
233233
}
234234

235235
nextSequenceNumber(): number {
@@ -686,7 +686,6 @@ class RuntimeOrchestrationEntityFeature implements OrchestrationEntityFeature {
686686
}
687687

688688
// Send unlock messages to all locked entities
689-
// Use _commitActions so they aren't cleared when the orchestration completes
690689
for (const entity of this.criticalSection.lockedEntities) {
691690
const actionId = this.context.nextSequenceNumber();
692691
const action = ph.newSendEntityMessageUnlockAction(
@@ -695,7 +694,7 @@ class RuntimeOrchestrationEntityFeature implements OrchestrationEntityFeature {
695694
entity.toString(),
696695
this.context.instanceId,
697696
);
698-
this.context._commitActions.push(action);
697+
this.context._pendingActions[action.getId()] = action;
699698
}
700699

701700
// Clear critical section state

0 commit comments

Comments
 (0)