Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Fix parallel execution continuing after a block errors (errors were being swallowed)
  • Workflow blocks now throw on child failure so error port routing works correctly
  • Skip empty loop/parallel validation when subflow is unreachable (disabled or disjoint)

Type of Change

  • Bug fix

Testing

  • Added 10 new engine tests for error handling scenarios
  • Added 3 new DAG builder tests for disabled subflow validation
  • All 460 executor tests pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 22, 2026 7:13pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Fixed critical bug where parallel execution continued after block errors occurred by implementing an error flag mechanism in the execution engine. Previously, errors in parallel branches were being swallowed via empty .catch(() => {}) handlers in trackExecution, causing execution to continue indefinitely. The fix introduces errorFlag and executionError to capture the first error, stop queuing new nodes, and properly propagate errors to callers.

Changes include:

  • Added error flag mechanism to stop execution loop when errors occur
  • Modified workflow handler to throw exceptions instead of returning error objects, enabling error port routing in BlockExecutor
  • Fixed DAG builder validation order to check sentinel node existence before validating empty loops/parallels, preventing false validation errors for disabled subflows
  • Added 13 comprehensive tests covering error handling scenarios

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes fix a critical bug with proper error handling, include comprehensive test coverage (13 new tests covering edge cases), and follow clean implementation patterns. The error flag mechanism is well-designed to capture only the first error while waiting for ongoing executions.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/executor/execution/engine.ts Added error flag mechanism to stop parallel execution when errors occur - captures first error and prevents new nodes from queuing
apps/sim/executor/handlers/workflow/workflow-handler.ts Changed from returning error objects to throwing exceptions for failed child workflows to enable error port routing
apps/sim/executor/dag/builder.ts Fixed validation to check sentinel node existence before validating empty loops/parallels, preventing errors for disabled subflows

Sequence Diagram

sequenceDiagram
    participant Engine as ExecutionEngine
    participant Queue as ReadyQueue
    participant Tracker as trackExecution
    participant Node1 as Node (Parallel 1)
    participant Node2 as Node (Parallel 2)
    participant ErrorFlag as errorFlag

    Engine->>Queue: initializeQueue()
    Engine->>Engine: while hasWork()
    
    loop Process Queue
        Engine->>Engine: Check errorFlag || cancellation
        alt errorFlag is true
            Engine->>Engine: break loop
        else continue
            Engine->>Queue: dequeue()
            Engine->>Node1: executeNode() [async]
            Engine->>Tracker: trackExecution(promise1)
            Tracker->>Tracker: promise.catch(error)
            Engine->>Node2: executeNode() [async]
            Engine->>Tracker: trackExecution(promise2)
            Tracker->>Tracker: promise.catch(error)
        end
    end

    Node1->>Node1: Execution fails
    Node1-->>Tracker: throw error
    Tracker->>ErrorFlag: Set errorFlag = true
    Tracker->>Tracker: Store executionError
    
    Engine->>Engine: Check errorFlag in next iteration
    Engine->>Engine: break loop (stop queuing new nodes)
    Engine->>Engine: waitForAllExecutions()
    
    Note over Engine,Node2: Node2 completes or fails,<br/>but no new nodes queued
    
    Engine->>Engine: if errorFlag && executionError
    Engine->>Engine: throw executionError
    
    Note over Engine: Error propagates to caller<br/>with preserved context
Loading

@waleedlatif1 waleedlatif1 merged commit f3ae3f8 into staging Jan 22, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/loop branch January 22, 2026 19:34
waleedlatif1 added a commit that referenced this pull request Jan 22, 2026
…lution consolidation, helm updates (#2946)

* improvement(workflow-item): stabilize avatar layout and fix name truncation (#2939)

* improvement(workflow-item): stabilize avatar layout and fix name truncation

* fix(avatars): revert overflow bg to hardcoded color for contrast

* fix(executor): stop parallel execution when block errors (#2940)

* improvement(helm): add per-deployment extraVolumes support (#2942)

* fix(gmail): expose messageId field in read email block (#2943)

* fix(resolver): consolidate reference resolution  (#2941)

* fix(resolver): consolidate code to resolve references

* fix edge cases

* use already formatted error

* fix multi index

* fix backwards compat reachability

* handle backwards compatibility accurately

* use shared constant correctly

* feat(router): expose reasoning output in router v2 block (#2945)

* fix(copilot): always allow, credential masking (#2947)

* Fix always allow, credential validation

* Credential masking

* Autoload

* fix(executor): handle condition dead-end branches in loops (#2944)

---------

Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com>
Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com>
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.

2 participants