Skip to content

Root runWorkflowLoop has inconsistent output behavior compared to its WorkflowNode children  #54

@Blisse

Description

@Blisse

In RealWorkflowLoop#runWorkflowLoop, the order of operations after an output for the root workflow's runWorkflowLoop is:

  1. output = select { .. }
  2. doRender
  3. output?.let { onOutput }

However, child workflows have their outputs immediately executed when the WorkflowAction is run.

  • From WorkflowNode#tick we call WorkflowNode#applyAction, but notice that we call output?.let(emitOutputToParent) immediately.

This difference in behavior manifests in the root workflow performing an extra render pass before the root workflow runner can receive an output and potentially end the workflow.

This extra render pass can cause a crash if the workflow does not expect to have render called after emitting an output (because the presumption is that the output stop the workflow from running).


To work around this, I can wrap my root workflow R in another workflow P that has 2 states: Running and CancelledAfterOutput. Initially, P will be in the Running state, and call renderChild on R. But after 1 output from R, P transitions to the CancelledAfterOutput state, which doesn't call renderChild on R. This "fixes" the errant extra render pass.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions