fix(execution): duplicate execution issue - #6316
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The client path treats that response as a duplicate runner, not a failed run: Tests cover the API JSON shape, client classification without console noise, and silent duplicate handling in the run-tool client. Reviewed by Cursor Bugbot for commit f93338e. Configure here. |
Greptile SummaryThe PR makes Copilot workflow execution claims server-authoritative so concurrent tabs or shared sessions can safely race without surfacing the losing request as an execution error.
Confidence Score: 5/5The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issues identified. The server atomically selects one execution owner, the winner remains responsible for confirming the single shared tool-call record, and the rejected client cleans up only its own tab-local execution state.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/workflows/[id]/execute/route.ts | Adds a stable conflict code to the existing atomic Copilot workflow claim rejection while retaining claim cleanup behavior. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-execution-utils.ts | Converts only the coded duplicate-claim response into a typed HTTP error and preserves normal console reporting for other failures. |
| apps/sim/hooks/use-execution-stream.ts | Extends the typed execution HTTP error with an optional machine-readable code without breaking existing constructors. |
| apps/sim/lib/copilot/tools/client/run-tool-execution.ts | Suppresses the benign losing side of a duplicate claim race while retaining the existing finally-based local cleanup. |
| apps/sim/lib/copilot/constants.ts | Defines the shared conflict-code constant used consistently by the route and client. |
| apps/sim/app/api/workflows/[id]/execute/route.async.test.ts | Verifies the coded 409 response and that execution does not proceed after a failed claim. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-execution-utils.test.ts | Verifies duplicate conflicts are typed and do not create misleading HTTP error console entries. |
| apps/sim/lib/copilot/tools/client/run-tool-execution.test.ts | Verifies a duplicate runner neither confirms nor surfaces an error and still clears its local execution pointer. |
Sequence Diagram
sequenceDiagram
participant A as Client tab A
participant B as Client tab B
participant API as Workflow execute API
participant DB as Copilot tool-call record
A->>API: Execute with toolCallId
B->>API: Execute with same toolCallId
API->>DB: Atomically claim for A
DB-->>API: Claim acquired
API-->>A: Start execution stream
API->>DB: Attempt claim for B
DB-->>API: Already claimed
API-->>B: 409 + conflict code
B->>B: Ignore duplicate and clear local state
A->>DB: Confirm shared tool-call completion
Reviews (1): Last reviewed commit: "fix(execution): duplicate execution issu..." | Re-trigger Greptile
Summary
Can now have duplicate executions across tabs/shared sessions and it wont error on replay paths either. Moving server authoritative id gen for idempotency key to prevent races.
Type of Change
Testing
Tested manually
Checklist