Skip to content

Commit bf0ea10

Browse files
icecrasher321emir-karabegadiologydevVikhyath Mondretiwaleedlatif1
authored
merge(staging-to-main) (#577)
* feat(agent): agent model dropdown combobox (#572) * feat: agent model dropdown combobox * fix(cli): package type for esm imports, missing realtime (#574) * fix: package type for esm imports, missing realtime calls and use of migrate * chore: bump cli * fix sourceBlock null check * fix(kb): fix kb navigation URLs * fix(csp): update CSP to allow for google drive picker * feat(dropdown): added optional icon to agent model dropdown --------- Co-authored-by: Aditya Tripathi <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Waleed Latif <[email protected]> * fix concurrent req check (#576) Co-authored-by: Vikhyath Mondreti <[email protected]> --------- Co-authored-by: Emir Karabeg <[email protected]> Co-authored-by: Aditya Tripathi <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Waleed Latif <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]>
1 parent 9be41b4 commit bf0ea10

File tree

9 files changed

+739
-21
lines changed

9 files changed

+739
-21
lines changed

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const runtime = 'nodejs'
2929
// Define the schema for environment variables
3030
const EnvVarsSchema = z.record(z.string())
3131

32-
// Keep track of running executions to prevent overlap
32+
// Keep track of running executions to prevent duplicate requests
33+
// Use a combination of workflow ID and request ID to allow concurrent executions with different inputs
3334
const runningExecutions = new Set<string>()
3435

3536
// Custom error class for usage limit exceeded
@@ -47,10 +48,14 @@ async function executeWorkflow(workflow: any, requestId: string, input?: any) {
4748
const workflowId = workflow.id
4849
const executionId = uuidv4()
4950

50-
// Skip if this workflow is already running
51-
if (runningExecutions.has(workflowId)) {
52-
logger.warn(`[${requestId}] Workflow is already running: ${workflowId}`)
53-
throw new Error('Workflow is already running')
51+
// Create a unique execution key combining workflow ID and request ID
52+
// This allows concurrent executions of the same workflow with different inputs
53+
const executionKey = `${workflowId}:${requestId}`
54+
55+
// Skip if this exact execution is already running (prevents duplicate requests)
56+
if (runningExecutions.has(executionKey)) {
57+
logger.warn(`[${requestId}] Execution is already running: ${executionKey}`)
58+
throw new Error('Execution is already running')
5459
}
5560

5661
// Check if the user has exceeded their usage limits
@@ -86,7 +91,7 @@ async function executeWorkflow(workflow: any, requestId: string, input?: any) {
8691
}
8792

8893
try {
89-
runningExecutions.add(workflowId)
94+
runningExecutions.add(executionKey)
9095
logger.info(`[${requestId}] Starting workflow execution: ${workflowId}`)
9196

9297
// Use the deployed state if available, otherwise fall back to current state
@@ -291,7 +296,7 @@ async function executeWorkflow(workflow: any, requestId: string, input?: any) {
291296
await persistExecutionError(workflowId, executionId, error, 'api')
292297
throw error
293298
} finally {
294-
runningExecutions.delete(workflowId)
299+
runningExecutions.delete(executionKey)
295300
}
296301
}
297302

@@ -392,7 +397,7 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
392397
}
393398
}
394399

395-
export async function OPTIONS(request: NextRequest) {
400+
export async function OPTIONS(_request: NextRequest) {
396401
return new NextResponse(null, {
397402
status: 200,
398403
headers: {

0 commit comments

Comments
 (0)