Skip to content

Conversation

@martmull
Copy link
Contributor

@martmull martmull commented Nov 7, 2025

as title

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

TODOs/FIXMEs:

  • // TODO: remove this so workflowRun updates are taken into account: packages/twenty-server/src/engine/core-modules/event-emitter/utils/object-record-changed-values.ts

Generated by 🚫 dangerJS against 0e5c20b

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.

Greptile Overview

Greptile Summary

Reverts the removal of workflowRun.state field from change detection filtering to prevent performance issues.

Context:

  • PR #15701 enabled real-time workflow run updates by removing the isWorkflowRunState check
  • This change caused intensive operations when comparing state field changes (which contains complex nested JSON with workflow steps and trigger data)
  • This PR re-adds the exclusion to restore performance

Changes:

  • Added back isWorkflowRunState helper function to identify workflowRun.state field
  • Added check to skip change detection for this field in objectRecordChangedValues
  • Included TODO comment noting this should eventually be removed to support workflow run updates

Trade-off:
This change improves performance but temporarily disables real-time updates for workflow run state changes until a more efficient solution is implemented.

Confidence Score: 4/5

  • Safe to merge with minor concerns about the temporary nature of the fix
  • The change correctly addresses a performance issue by reverting a problematic optimization. The code follows existing patterns and includes a TODO for future improvement. Score of 4 (not 5) because this creates a regression in functionality (disabling real-time workflow run updates) and represents a temporary workaround rather than a permanent solution.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/core-modules/event-emitter/utils/object-record-changed-values.ts 4/5 Re-adds isWorkflowRunState check to skip change detection for workflowRun.state field, preventing intensive operations that caused performance issues

Sequence Diagram

sequenceDiagram
    participant Client as Client/Frontend
    participant ORM as TwentyORM
    participant Formatter as Event Formatter
    participant ChangedValues as objectRecordChangedValues
    participant EventEmitter as Event Emitter
    
    Client->>ORM: Update workflowRun record
    ORM->>Formatter: formatTwentyOrmEventToDatabaseBatchEvent
    Formatter->>ChangedValues: objectRecordChangedValues(before, after, metadata)
    
    alt workflowRun.state field
        ChangedValues->>ChangedValues: isWorkflowRunState() check
        Note over ChangedValues: Returns true for workflowRun.state
        ChangedValues->>ChangedValues: Skip field (return acc)
        Note over ChangedValues: Avoids expensive deepEqual<br/>on complex JSON structure
    else Other fields
        ChangedValues->>ChangedValues: deepEqual(oldValue, newValue)
        ChangedValues->>ChangedValues: Include in diff if changed
    end
    
    ChangedValues-->>Formatter: Return changed fields diff
    
    alt No changes detected
        Formatter->>Formatter: Filter out event (no updatedFields)
        Note over Formatter: Event not emitted if no changes
    else Changes detected
        Formatter->>EventEmitter: Emit update event with diff
        EventEmitter->>Client: Real-time update notification
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:22353

This environment will automatically shut down when the PR is closed or after 5 hours.

@charlesBochet
Copy link
Member

@martmull let's implement a proper solution, production should be fine and it's important to keep the real time updates on workflowRuns

@martmull martmull deleted the remove-cpu-intensive-operation branch November 11, 2025 16:18
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.

3 participants