Skip to content

A body that awaits its step but forgets done() is refused as unawaited_step #183

Description

@kjgbot

Found while restoring the tests dropped in #140 (see #166).

This body awaits its only step and never completes:

flow('missing-completion', async (f) => {
  await f.run('emit:ran');
});

It is correctly refused — but as:

unawaited_step: flow "missing-completion" returned with unawaited steps: ...

The step was awaited. The actual defect is the missing done(), and there is a code for exactly that: missing_completion.

Why it lands there

In authored-flow-executor.ts, verifyAuthoredOperations(...) runs before the completion check:

await verifyAuthoredOperations(definition.name, authoredSteps, lifecycle);
...
if (requestedCompletion === undefined) {
  throw new AuthoredFlowExecutionError('missing_completion', ...);
}

So for any body with a journal-backed step, the verification refusal wins and missing_completion is never evaluated.

Measured, not assumed

Disabling the completion check entirely (if (false && requestedCompletion === undefined)) left every test in authored-flow.test.ts green — including the restored case that was originally written to assert missing_completion. That is what showed the code is unreachable for this shape.

#166 adds refuses a body that completes nothing at all (a body with no operations at all), which does reach it and fails under that same mutation. So the path is covered now, but only via the no-steps shape.

Why it is worth fixing

The message is actively misleading: it tells an author to await something they already awaited, and says nothing about the thing they actually forgot. Someone debugging this reads "unawaited steps", checks their awaits, and finds nothing wrong.

Likely fix is ordering or classification — either evaluate the completion requirement before operation verification, or have unawaited_step exclude operations that did settle. I have not attempted either; the restored test asserts the refusal's class rather than its code so it neither fails on main nor bakes in the current label.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions