Skip to content

Commit de752fa

Browse files
committed
fix workflow tool react query
1 parent 969a478 commit de752fa

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

apps/sim/hooks/queries/workflows.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export function useWorkflowInputFields(workflowId: string | undefined) {
5252
queryKey: workflowKeys.inputFields(workflowId),
5353
queryFn: () => fetchWorkflowInputFields(workflowId!),
5454
enabled: Boolean(workflowId),
55-
staleTime: 60 * 1000, // 1 minute cache
55+
staleTime: 0,
56+
refetchOnMount: 'always',
5657
})
5758
}
5859

apps/sim/tools/params.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,6 @@ export interface ToolWithParameters {
324324

325325
let blockConfigCache: Record<string, BlockConfig> | null = null
326326

327-
const workflowInputFieldsCache = new Map<
328-
string,
329-
{ fields: Array<{ name: string; type: string }>; timestamp: number }
330-
>()
331-
const WORKFLOW_CACHE_TTL = 5 * 60 * 1000 // 5 minutes
332-
333327
function getBlockConfigurations(): Record<string, BlockConfig> {
334328
if (!blockConfigCache) {
335329
try {
@@ -726,18 +720,12 @@ async function applyDynamicSchemaForWorkflow(
726720
}
727721

728722
/**
729-
* Helper function to fetch workflow input fields with caching
723+
* Fetches workflow input fields from the API.
724+
* No local caching - relies on React Query caching on the client side.
730725
*/
731726
async function fetchWorkflowInputFields(
732727
workflowId: string
733728
): Promise<Array<{ name: string; type: string }>> {
734-
const cached = workflowInputFieldsCache.get(workflowId)
735-
const now = Date.now()
736-
737-
if (cached && now - cached.timestamp < WORKFLOW_CACHE_TTL) {
738-
return cached.fields
739-
}
740-
741729
try {
742730
const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http')
743731

@@ -750,10 +738,7 @@ async function fetchWorkflowInputFields(
750738
}
751739

752740
const { data } = await response.json()
753-
const fields = extractInputFieldsFromBlocks(data?.state?.blocks)
754-
workflowInputFieldsCache.set(workflowId, { fields, timestamp: now })
755-
756-
return fields
741+
return extractInputFieldsFromBlocks(data?.state?.blocks)
757742
} catch (error) {
758743
logger.error('Error fetching workflow input fields:', error)
759744
return []

0 commit comments

Comments
 (0)