Skip to content

Commit a25f7e2

Browse files
Pass compensation closures to all() instead of pre-resolving them
Workflow::compensate() with parallelCompensation=true called each compensation closure inside the foreach loop, then passed the resolved scalar results to all(). AllCall rejects anything that isn't an ActivityCall, ChildWorkflowCall, or nested AllCall, so the parallel branch threw LogicException on the first compensation that returned a scalar — killing the workflow before it could complete. Pass the closures themselves: all() runs each one through whileInactive() so activity()/child() inside the closure returns the call object instead of suspending the fiber, which is what AllCall expects. Refs #399 (bucket D — parallel saga completion-condition failures) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 31bfb20 commit a25f7e2

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/V2/Workflow.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,20 @@ public function compensate(): void
144144
$reversed = array_reverse($this->compensations);
145145

146146
if ($this->parallelCompensation) {
147-
$calls = [];
148-
149-
foreach ($reversed as $compensation) {
150-
$calls[] = $compensation();
151-
}
152-
147+
// Pass each compensation closure directly to all(): it uses
148+
// whileInactive() to capture the ActivityCall/ChildWorkflowCall the
149+
// closure produces without executing it serially in-fiber. Calling
150+
// $compensation() here would resolve the activity synchronously and
151+
// hand all() plain string results, which it rejects (AllCall only
152+
// accepts the call objects).
153153
if ($this->continueWithError) {
154154
try {
155-
all($calls);
155+
all($reversed);
156156
} catch (Throwable) {
157157
// continueWithError applies uniformly: swallow parallel compensation failures
158158
}
159159
} else {
160-
all($calls);
160+
all($reversed);
161161
}
162162
} else {
163163
foreach ($reversed as $compensation) {

0 commit comments

Comments
 (0)