Skip to content

Commit 250668f

Browse files
committed
fix(deploy): use sequential-then-parallel pattern in checkNeedsRedeployment
1 parent c64a9fa commit 250668f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

apps/sim/app/api/workflows/utils.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,29 @@ export function createSuccessResponse(data: any) {
3232
* both the /deploy and /status endpoints to ensure consistent results.
3333
*/
3434
export async function checkNeedsRedeployment(workflowId: string): Promise<boolean> {
35-
const [[active], normalizedData, [workflowRecord]] = await Promise.all([
36-
db
37-
.select({ state: workflowDeploymentVersion.state })
38-
.from(workflowDeploymentVersion)
39-
.where(
40-
and(
41-
eq(workflowDeploymentVersion.workflowId, workflowId),
42-
eq(workflowDeploymentVersion.isActive, true)
43-
)
35+
const [active] = await db
36+
.select({ state: workflowDeploymentVersion.state })
37+
.from(workflowDeploymentVersion)
38+
.where(
39+
and(
40+
eq(workflowDeploymentVersion.workflowId, workflowId),
41+
eq(workflowDeploymentVersion.isActive, true)
4442
)
45-
.orderBy(desc(workflowDeploymentVersion.createdAt))
46-
.limit(1),
43+
)
44+
.orderBy(desc(workflowDeploymentVersion.createdAt))
45+
.limit(1)
46+
47+
if (!active?.state) return false
48+
49+
const [normalizedData, [workflowRecord]] = await Promise.all([
4750
loadWorkflowFromNormalizedTables(workflowId),
4851
db
4952
.select({ variables: workflow.variables })
5053
.from(workflow)
5154
.where(eq(workflow.id, workflowId))
5255
.limit(1),
5356
])
54-
55-
if (!active?.state || !normalizedData) return false
57+
if (!normalizedData) return false
5658

5759
const currentState = {
5860
blocks: normalizedData.blocks,

0 commit comments

Comments
 (0)