Skip to content

Ignore stale workflow handler runs and failure notifications - #330

Merged
ianmacartney merged 3 commits into
mainfrom
ian/failed-fan-in-duplicates
Nov 12, 2026
Merged

ianmacartney merged 3 commits into
mainfrom
ian/failed-fan-in-duplicates

Conversation

@ianmacartney

Copy link
Copy Markdown
Member

Refs #327, #328.

Each completing step enqueues a handler run, so N parallel steps queue N runs of one generation. Once the workflow has failed, the remaining runs replay the handler, throw Workflow not running from complete, and are recorded as Workpool failures. Each of those then triggers a handlerOnComplete that throws the same error.

Changes

  • workflowMutation returns early for any finished run, not only a successful one.
  • workflowMutation checks the generation and terminal state before the oversized-journal branch, so a stale run no longer calls complete.
  • handlerOnComplete logs and returns when its workflow is absent, at another generation, or already finished. A live workflow is still failed as before; a malformed id still goes through completeHandler.
  • completeHandler's error interpolates the workflow id instead of [object Object].

Step completion still enqueues the handler unconditionally. The duplicate runs are still queued; they now return without replaying.

Measured

30 parallel steps followed by a throwing handler, in convex-test:

Before After
Handler replays 11 4
Handler work items recorded as failed 7 0
Workflow not running errors 14 0

Tests

  • example/convex/test/fanIn.test.ts: fan-in that fails or succeeds replays once and reports no handler failures; a duplicate run of a finished workflow does not replay.
  • src/component/workflow.test.ts: handlerOnComplete against live, finished, restarted, canceled and cleaned-up workflows; a stale-generation run with a journal over the size limit.

example/convex/_generated/api.d.ts was edited by hand to add the new test module.

N parallel steps queue N handler runs of one generation. After the workflow
failed, the extra runs replayed the handler, threw "Workflow not running"
from complete, and were recorded as Workpool failures, each followed by a
failing handlerOnComplete (#327, #328).

- workflowMutation returns for any finished run, and checks generation and
  terminal state before failing on an oversized journal.
- handlerOnComplete returns when its workflow is gone, at another
  generation, or already finished.
- completeHandler's error names the workflow id.
@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/workflow@330

commit: d62e8b7

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .changeset/failed-fan-in-duplicates.md Resolved
* Skip reading the journal of a finished workflow

journal.load with shortCircuit returns no entries when the workflow has a
result. workflowMutation returns before using the journal in that case, so
duplicate handler runs no longer read up to the journal size limit.

* Test the journal short circuit with a journal over the size limit
@ianmacartney
ianmacartney merged commit 287c99a into main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant