Skip to content

Commit 96f2f94

Browse files
icecrasher321waleedlatif1
authored andcommitted
fix(frozen-canvas): need to fetch the deployment version correctly (#2552)
1 parent 4f5d57b commit 96f2f94

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

apps/sim/lib/logs/execution/logging-factory.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { BASE_EXECUTION_CHARGE } from '@/lib/billing/constants'
22
import type { ExecutionEnvironment, ExecutionTrigger, WorkflowState } from '@/lib/logs/types'
3-
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
3+
import {
4+
loadDeployedWorkflowState,
5+
loadWorkflowFromNormalizedTables,
6+
} from '@/lib/workflows/persistence/utils'
47

58
export function createTriggerObject(
69
type: ExecutionTrigger['type'],
@@ -47,6 +50,24 @@ export async function loadWorkflowStateForExecution(workflowId: string): Promise
4750
}
4851
}
4952

53+
/**
54+
* Load deployed workflow state for logging purposes.
55+
* This fetches the active deployment state, ensuring logs capture
56+
* the exact state that was executed (not the live editor state).
57+
*/
58+
export async function loadDeployedWorkflowStateForLogging(
59+
workflowId: string
60+
): Promise<WorkflowState> {
61+
const deployedData = await loadDeployedWorkflowState(workflowId)
62+
63+
return {
64+
blocks: deployedData.blocks || {},
65+
edges: deployedData.edges || [],
66+
loops: deployedData.loops || {},
67+
parallels: deployedData.parallels || {},
68+
}
69+
}
70+
5071
export function calculateCostSummary(traceSpans: any[]): {
5172
totalCost: number
5273
totalInputCost: number

apps/sim/lib/logs/execution/logging-session.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
calculateCostSummary,
66
createEnvironmentObject,
77
createTriggerObject,
8+
loadDeployedWorkflowStateForLogging,
89
loadWorkflowStateForExecution,
910
} from '@/lib/logs/execution/logging-factory'
1011
import type {
@@ -78,7 +79,11 @@ export class LoggingSession {
7879
workspaceId,
7980
variables
8081
)
81-
this.workflowState = await loadWorkflowStateForExecution(this.workflowId)
82+
// Use deployed state if deploymentVersionId is provided (non-manual execution)
83+
// Otherwise fall back to loading from normalized tables (manual/draft execution)
84+
this.workflowState = deploymentVersionId
85+
? await loadDeployedWorkflowStateForLogging(this.workflowId)
86+
: await loadWorkflowStateForExecution(this.workflowId)
8287

8388
// Only create a new log entry if not resuming
8489
if (!skipLogCreation) {
@@ -295,7 +300,7 @@ export class LoggingSession {
295300
workspaceId,
296301
variables
297302
)
298-
// Minimal workflow state when normalized data is unavailable
303+
// Minimal workflow state when normalized/deployed data is unavailable
299304
this.workflowState = {
300305
blocks: {},
301306
edges: [],

apps/sim/lib/workflows/executor/execution-core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ export async function executeWorkflowCore(
179179
userId,
180180
workspaceId: providedWorkspaceId,
181181
variables,
182-
skipLogCreation, // Skip if resuming an existing execution
183-
deploymentVersionId, // Only set for deployed executions
182+
skipLogCreation,
183+
deploymentVersionId,
184184
})
185185

186186
// Process block states with env var substitution using pre-decrypted values

0 commit comments

Comments
 (0)