From 3f0b9dc956fc817d2122d4451cfdf93c730a4658 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Wed, 6 Aug 2025 11:00:54 -0700 Subject: [PATCH 1/2] Fix yaml export race condition --- .../components/export-controls/export-controls.tsx | 4 ++-- apps/sim/lib/environment.ts | 2 +- apps/sim/stores/workflows/yaml/store.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls/export-controls.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls/export-controls.tsx index 9551dd4ec87..540d6075262 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls/export-controls.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls/export-controls.tsx @@ -37,7 +37,7 @@ export function ExportControls({ disabled = false }: ExportControlsProps) { } } - const handleExportYaml = () => { + const handleExportYaml = async () => { if (!currentWorkflow || !activeWorkflowId) { logger.warn('No active workflow to export') return @@ -45,7 +45,7 @@ export function ExportControls({ disabled = false }: ExportControlsProps) { setIsExporting(true) try { - const yamlContent = getYaml() + const yamlContent = await getYaml() const filename = `${currentWorkflow.name.replace(/[^a-z0-9]/gi, '-')}.yaml` downloadFile(yamlContent, filename, 'text/yaml') diff --git a/apps/sim/lib/environment.ts b/apps/sim/lib/environment.ts index d6da01ec546..cfffb33186d 100644 --- a/apps/sim/lib/environment.ts +++ b/apps/sim/lib/environment.ts @@ -11,7 +11,7 @@ export const isProd = env.NODE_ENV === 'production' /** * Is the application running in development mode */ -export const isDev = env.NODE_ENV === 'development' +export const isDev = false // env.NODE_ENV === 'development' /** * Is the application running in test mode diff --git a/apps/sim/stores/workflows/yaml/store.ts b/apps/sim/stores/workflows/yaml/store.ts index 294a2e1ca5f..afe8929bb0a 100644 --- a/apps/sim/stores/workflows/yaml/store.ts +++ b/apps/sim/stores/workflows/yaml/store.ts @@ -13,7 +13,7 @@ interface WorkflowYamlState { interface WorkflowYamlActions { generateYaml: () => Promise - getYaml: () => string + getYaml: () => Promise refreshYaml: () => void } @@ -151,7 +151,7 @@ export const useWorkflowYamlStore = create()( } }, - getYaml: () => { + getYaml: async () => { // Initialize subscriptions on first use initializeSubscriptions() @@ -160,7 +160,7 @@ export const useWorkflowYamlStore = create()( // Auto-refresh if data is stale (older than 1 second) or never generated if (!lastGenerated || currentTime - lastGenerated > 1000) { - get().generateYaml() + await get().generateYaml() return get().yaml } From a6d67b87ecc0d8a7ad1fc67bd3b2c06981e42de1 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Wed, 6 Aug 2025 11:11:50 -0700 Subject: [PATCH 2/2] Fix env.ts dev --- apps/sim/lib/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/lib/environment.ts b/apps/sim/lib/environment.ts index cfffb33186d..d6da01ec546 100644 --- a/apps/sim/lib/environment.ts +++ b/apps/sim/lib/environment.ts @@ -11,7 +11,7 @@ export const isProd = env.NODE_ENV === 'production' /** * Is the application running in development mode */ -export const isDev = false // env.NODE_ENV === 'development' +export const isDev = env.NODE_ENV === 'development' /** * Is the application running in test mode