Skip to content

fix: parallel/pipeline 不应吞掉工作流取消异常 - #1348

Open
ai-yang wants to merge 1 commit into
claude-code-best:mainfrom
ai-yang:audit/fix-workflow-abort
Open

fix: parallel/pipeline 不应吞掉工作流取消异常#1348
ai-yang wants to merge 1 commit into
claude-code-best:mainfrom
ai-yang:audit/fix-workflow-abort

Conversation

@ai-yang

@ai-yang ai-yang commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • parallel()pipeline() 中重新抛出 WorkflowAbortedError
  • 普通 thunk/stage 异常继续按既有契约记录 warning 并返回 null
  • 增加 hooks 单元测试和 runWorkflow 端到端状态测试。

修复后,用户取消组合 workflow 时,result、run_done 事件和持久化终态都保持为 killed,不会错误显示 completed: [null]

Test plan

  • bun test packages/workflow-engine/src/__tests__/hooks.test.ts packages/workflow-engine/src/__tests__/runWorkflow.test.ts(61 pass)
  • bun run typecheck
  • Biome check(改动文件)
  • git diff --check

关联 issue

Closes #1345

Summary by CodeRabbit

  • Bug Fixes

    • Improved workflow cancellation handling for parallel and pipeline executions.
    • Aborted workflows now correctly report a killed status and emit the final completion event.
    • Other execution errors continue to use the existing warning and fallback behavior.
  • Tests

    • Added coverage for cancellation handling in parallel, pipeline, and end-to-end workflow runs.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

parallel and pipeline now rethrow WorkflowAbortedError. New tests verify direct propagation and killed statuses in workflow results and terminal run_done events.

Changes

Workflow cancellation handling

Layer / File(s) Summary
Propagate cancellation through combinators
packages/workflow-engine/src/engine/hooks.ts
parallel and pipeline rethrow WorkflowAbortedError. Other errors remain logged and converted to null.
Validate killed workflow results
packages/workflow-engine/src/__tests__/hooks.test.ts, packages/workflow-engine/src/__tests__/runWorkflow.test.ts
Tests verify cancellation propagation and killed statuses for workflow results and terminal run_done events.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: preventing parallel and pipeline from swallowing workflow cancellation errors.
Linked Issues check ✅ Passed The changes rethrow WorkflowAbortedError in both combinators and add regression tests for killed results and run_done events [#1345].
Out of Scope Changes check ✅ Passed All changes are limited to the cancellation fix and its unit and end-to-end regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ai-yang
ai-yang marked this pull request as ready for review August 11, 2026 11:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/workflow-engine/src/__tests__/runWorkflow.test.ts (1)

217-223: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add an assertion for the persisted terminal state.

The test checks result.status and the final run_done event. It does not check the persisted run record. A persistence regression could still store completed: [null] while this test passes. Read the persisted state, or assert the persistence call, for both workflow cases and require status === 'killed'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/workflow-engine/src/__tests__/runWorkflow.test.ts` around lines 217
- 223, Extend the affected workflow tests around the result status and final
run_done assertions to also verify the persisted run record for both workflow
cases. Read the stored state or inspect the persistence call, and require its
status to be 'killed', guarding against a persisted completed value of [null].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/workflow-engine/src/__tests__/runWorkflow.test.ts`:
- Around line 217-223: Extend the affected workflow tests around the result
status and final run_done assertions to also verify the persisted run record for
both workflow cases. Read the stored state or inspect the persistence call, and
require its status to be 'killed', guarding against a persisted completed value
of [null].

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6647c3d7-8b52-45fa-85c6-dcd798bdb649

📥 Commits

Reviewing files that changed from the base of the PR and between 3bb6b57 and b7d8458.

📒 Files selected for processing (3)
  • packages/workflow-engine/src/__tests__/hooks.test.ts
  • packages/workflow-engine/src/__tests__/runWorkflow.test.ts
  • packages/workflow-engine/src/engine/hooks.ts

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