Description
What happens
wake in apps/server/src/workflows/WorkflowEngine.ts checks whether a run is paused and then delivers the wake in a separate step:
const wake = Effect.fnUntraced(function* (wait, value) {
if (resuming.has(wait.run_id) || (yield* store.run(wait.run_id))?.status === "paused") return;
yield* send(wait, value);
});The comment above it says why the check exists: the engine would replay a paused run for the wake and run its failed step again unasked, so for a paused run the claim keeps the value and the resume sends it.
If a sibling step fails and pauses the run between the status read and send, the delivery still goes out. The engine then replays the run and runs the failed step again without anyone resuming it. This applies to every wake that goes through here: an answer, a timeout, a withdrawal, a signal.
Raised in review of #42506; the code predates that change.
Expected
A run that is paused when the wake is delivered is not resumed by it. The value stays with the claim and is sent on an explicit resume, as for a run that was already paused at the check.
Notes
- Not reproduced in a running server; found by reading. A test needs a workflow with a failing step beside an open wait (the
doubtingfixture inWorkflows.test.tshas that shape) and a way to make the step fail between the read and the send. - The review did not find an existing store operation that makes the check and the delivery atomic with respect to a pause. Either the pause is applied so a later delivery cannot resume the run, or the delivery is held until the explicit resume.
Acceptance
- A test where the run pauses between the status read and the delivery: the failed step does not run again until the run is resumed, and the waited-on value is delivered on that resume.
- Wakes for runs that are not paused behave as today.
Activity
fix(server): a failed step stays failed when a wake preempts its run
fix(server): a step of a paused run waits for the resume