Skip to content

Conversation

@skwowet
Copy link
Member

@skwowet skwowet commented Dec 16, 2025

Changes

  • Switched from REJECT_DUPLICATE to ALLOW_DUPLICATE workflow reuse policy to allow starting new workflows after the previous one completed, failed, or was cancelled
  • Added workflowIdConflictPolicy: FAIL to prevent concurrent workflows with the same ID
  • Added pre-check to wait for running workflows before attempting to start a new one
  • Renamed from recalculateActivityAffiliationsOfOrganizationSynchronous to recalculateActivityAffiliationsOfOrganizationAsync - no longer waits for the organization update workflow to complete, as organizations with many members can take some time to process
  • Applied same changes to member affiliation workflows for consistency

Behavior

  • If a workflow is already running, new triggers wait for it to complete before starting a new one
  • If the previous workflow is in a terminal state (completed, failed, or canceled), a new workflow starts immediately
  • Concurrent triggers collapse into a single follow-up run via conflict policy
  • Ensures only one workflow per entity runs at any time

Note

Switch Temporal policies to allow reuse but fail conflicts, wait for running workflows, and make organization affiliation recalculation async, applying the same pattern to members and updating workflow callers/exports.

  • Temporal workflow handling:
    • Use WorkflowIdReusePolicy.ALLOW_DUPLICATE with WorkflowIdConflictPolicy.FAIL for memberUpdate and organizationUpdate.
    • Pre-check existing handles; wait for RUNNING workflows before starting new ones; skip on WorkflowExecutionAlreadyStartedError.
  • Organizations:
    • Rename recalculateActivityAffiliationsOfOrganizationSynchronousrecalculateActivityAffiliationsOfOrganizationAsync and stop awaiting completion.
    • Update start args for organizationUpdate unchanged; introduce conflict/reuse policies and pre-check logic.
  • Members:
    • Apply identical conflict/reuse policies and pre-check logic to recalculateActivityAffiliationsOfMemberAsync.
  • Workflows and exports:
    • Update imports/exports and workflow calls to use recalculateActivityAffiliationsOfOrganizationAsync during unmerge.
    • Central activities.ts reflects renamed org function.

Written by Cursor Bugbot for commit 448af25. This will update automatically on new commits. Configure here.

@skwowet skwowet self-assigned this Dec 16, 2025
@skwowet skwowet changed the title fix: handle organizationUpdate duplicate start during unmerge fix: handle organizationUpdate duplicate start during unmerge (CM-852) Dec 16, 2025
@skwowet skwowet marked this pull request as ready for review December 16, 2025 14:49
@skwowet skwowet requested review from epipav and themarolt December 16, 2025 14:49
@skwowet skwowet merged commit 3efbbbe into main Dec 17, 2025
17 checks passed
@skwowet skwowet deleted the bugfix/CM-852 branch December 17, 2025 09:14
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.

4 participants