Skip to content

fix(client-exec): send correct client workflow state override#3143

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/client-exec-race-cond
Feb 5, 2026
Merged

fix(client-exec): send correct client workflow state override#3143
icecrasher321 merged 1 commit intostagingfrom
fix/client-exec-race-cond

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Need to send client side state as workflow state override correctly since db is out of sync for 1-2 seconds so validations must run on the former.

Type of Change

  • Bug fix

Testing

Tested manually

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 Feb 5, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 5, 2026 7:35am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 5, 2026

Greptile Overview

Greptile Summary

Fixed workflow execution validation by ensuring the client-side workflow state is always sent to the server as workflowStateOverride. Previously, this override was only sent conditionally when executionWorkflowState existed, causing validations to run against stale database state that can be 1-2 seconds behind.

Key Changes:

  • Extracted client workflow state construction into a dedicated variable (clientWorkflowState)
  • Changed workflowStateOverride from conditionally undefined to always passing the current client state
  • This ensures server-side validations use the same state the client is working with, preventing false validation errors due to DB sync delays

Confidence Score: 5/5

  • This PR is safe to merge - it's a focused bug fix that resolves a race condition
  • The change is minimal, well-scoped, and directly addresses the stated issue. The logic is sound: instead of conditionally sending workflow state, it now always sends the current client-side state to prevent validation against stale DB data
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts Ensures workflowStateOverride is always sent with client workflow state, fixing validation timing issues

Sequence Diagram

sequenceDiagram
    participant Client as useWorkflowExecution
    participant Stream as executionStream
    participant API as /api/workflows/execute
    participant Core as execution-core.ts
    participant DB as Database

    Note over Client: User triggers execution
    
    Client->>Client: Read latest workflow state from store
    Client->>Client: Build clientWorkflowState object
    Note over Client: BEFORE: conditionally sent override<br/>AFTER: always sent override
    
    Client->>Stream: execute({ workflowStateOverride })
    Note over Stream: workflowStateOverride always defined now
    
    Stream->>API: POST with workflowStateOverride
    API->>Core: executeWorkflowCore(snapshot)
    Note over Core: snapshot.metadata.workflowStateOverride
    
    alt workflowStateOverride present
        Core->>Core: Use client-side state (blocks, edges, loops, parallels)
        Note over Core: Validates against current client state<br/>DB may be 1-2 seconds behind
    else no override (old behavior)
        Core->>DB: Load draft state from DB
        Note over Core: Validates against DB state<br/>May be stale for 1-2 seconds
    end
    
    Core->>Core: Run validations on workflow state
    Core-->>API: Execution result
    API-->>Stream: SSE events stream
    Stream-->>Client: Callbacks invoked
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@icecrasher321 icecrasher321 merged commit 2d7e6c9 into staging Feb 5, 2026
12 checks passed
@icecrasher321 icecrasher321 deleted the fix/client-exec-race-cond branch February 5, 2026 07:53
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