Repository navigation
Workflow (saga) timeouts #259
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestroadmapPart of the project roadmapPart of the project roadmap
Milestone
Description
Context
Timeouts are the most common saga need: "if payment isn't received in 24h, cancel the order".
Messages sent from a workflow handler already carry stickyAttributes.workflowId, and the default when lookup maps it back to $workflowId. So once #258 lands, a delayed send from a workflow handler is already a timeout routed to its instance.
The gap is noise. A message for a completed workflow logs No existing workflow state found for message. Ignoring. at error level in WorkflowRegistry, and a timeout would trip that routinely.
Decisions
Answered by the maintainer:
- No timeout API. A timeout is
ctx.send(new PaymentTimedOut(...), { deliverAfter }), handled with.when(PaymentTimedOut, ...). It's an ordinary message, type-checked by the existing workflow mapper checks.
Proposed:
- A message whose workflow instance has completed or been discarded is dropped and logged at
debug. On a miss, the registry re-queries withincludeCompletedto tell "completed" apart from "never existed". "Never existed" stays a warning or error. - There's no cancellation: the timeout handler checks the state and ignores itself if the step already happened.
- Time control in tests is Handler and workflow test helpers #265's job: its workflow scenario runner records delayed sends and delivers them with
advanceTime.
Non-goals
- Cancelling a timeout.
- A timeout-specific mapper method or a
requestTimeouthelper. - Fake clocks.
Approach
WorkflowRegistry: the miss handling described in decision 2. No new persistence methods;getWorkflowState(..., includeCompleted)already exists in every persistence.- Integration tests in bus-core for class workflows and
defineWorkflowworkflows, using the in-memory transport. - Docs page
/guide/workflows/timeoutswith snippets for both workflow styles.
Acceptance criteria
- A delayed send from a workflow handler is handled by that workflow instance only
- A timeout that arrives after the workflow completed is ignored, logged at debug, not error
- Tests for class and function workflows
- Docs page and snippets; changeset
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestroadmapPart of the project roadmapPart of the project roadmap
Activity
adenhertog commentedon Oct 3, 2026
When this lands, update the request/reply guide (
docs/guide/workflows/request-reply.md, added in #330) to show timing out a reply that never arrives, and link to the timeouts page from it.