perf(editor): Avoid deep watch on execution result data (#15304)

This commit is contained in:
Suguru Inoue
2025-05-12 17:01:39 +02:00
committed by GitHub
parent 52bf9203f0
commit cd2e2dc8d9
3 changed files with 10 additions and 11 deletions

View File

@@ -5,7 +5,6 @@ import { Workflow } from 'n8n-workflow';
import { useWorkflowsStore } from '@/stores/workflows.store'; import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNodeHelpers } from '@/composables/useNodeHelpers'; import { useNodeHelpers } from '@/composables/useNodeHelpers';
import { useThrottleFn } from '@vueuse/core'; import { useThrottleFn } from '@vueuse/core';
import { IN_PROGRESS_EXECUTION_ID } from '@/constants';
import { import {
createLogEntries, createLogEntries,
deepToRaw, deepToRaw,
@@ -58,13 +57,6 @@ export function useExecutionData() {
}; };
}); });
const updateInterval = computed(() => ((execution.value?.tree.length ?? 0) > 10 ? 300 : 0)); const updateInterval = computed(() => ((execution.value?.tree.length ?? 0) > 10 ? 300 : 0));
const runStatusList = computed(() =>
workflowsStore.workflowExecutionData?.id === IN_PROGRESS_EXECUTION_ID
? Object.values(workflowsStore.workflowExecutionData?.data?.resultData.runData ?? {})
.flatMap((tasks) => tasks.map((task) => task.executionStatus ?? ''))
.join('|')
: '',
);
function resetExecutionData() { function resetExecutionData() {
execData.value = undefined; execData.value = undefined;
@@ -78,7 +70,7 @@ export function useExecutionData() {
() => workflowsStore.workflowExecutionData?.id, () => workflowsStore.workflowExecutionData?.id,
() => workflowsStore.workflowExecutionData?.workflowData.id, () => workflowsStore.workflowExecutionData?.workflowData.id,
() => workflowsStore.workflowExecutionData?.status, () => workflowsStore.workflowExecutionData?.status,
runStatusList, () => workflowsStore.workflowExecutionResultDataLastUpdate,
], ],
useThrottleFn( useThrottleFn(
() => { () => {

View File

@@ -806,11 +806,11 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
); );
watch( watch(
() => workflowsStore.workflowExecutionData?.data?.resultData ?? {}, () => workflowsStore.workflowExecutionResultDataLastUpdate,
() => { () => {
workflowExecutionDataStale.value = true; workflowExecutionDataStale.value = true;
}, },
{ deep: true, immediate: true }, { immediate: true },
); );
return { return {

View File

@@ -141,6 +141,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const activeWorkflowExecution = ref<ExecutionSummary | null>(null); const activeWorkflowExecution = ref<ExecutionSummary | null>(null);
const currentWorkflowExecutions = ref<ExecutionSummary[]>([]); const currentWorkflowExecutions = ref<ExecutionSummary[]>([]);
const workflowExecutionData = ref<IExecutionResponse | null>(null); const workflowExecutionData = ref<IExecutionResponse | null>(null);
const workflowExecutionResultDataLastUpdate = ref<number>();
const workflowExecutionPairedItemMappings = ref<Record<string, Set<string>>>({}); const workflowExecutionPairedItemMappings = ref<Record<string, Set<string>>>({});
const subWorkflowExecutionError = ref<Error | null>(null); const subWorkflowExecutionError = ref<Error | null>(null);
const executionWaitingForWebhook = ref(false); const executionWaitingForWebhook = ref(false);
@@ -866,6 +867,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
} }
workflowExecutionData.value = workflowResultData; workflowExecutionData.value = workflowResultData;
workflowExecutionPairedItemMappings.value = getPairedItemsMapping(workflowResultData); workflowExecutionPairedItemMappings.value = getPairedItemsMapping(workflowResultData);
workflowExecutionResultDataLastUpdate.value = Date.now();
} }
function setWorkflowExecutionRunData(workflowResultData: IRunExecutionData) { function setWorkflowExecutionRunData(workflowResultData: IRunExecutionData) {
@@ -874,6 +876,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
...workflowExecutionData.value, ...workflowExecutionData.value,
data: workflowResultData, data: workflowResultData,
}; };
workflowExecutionResultDataLastUpdate.value = Date.now();
} }
} }
@@ -1497,6 +1500,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
executionTime: 0, executionTime: 0,
...data.data, ...data.data,
}); });
workflowExecutionResultDataLastUpdate.value = Date.now();
} }
} }
@@ -1545,6 +1549,8 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
tasksData.push(data); tasksData.push(data);
} }
workflowExecutionResultDataLastUpdate.value = Date.now();
void trackNodeExecution(pushData); void trackNodeExecution(pushData);
} }
} }
@@ -1830,6 +1836,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
currentWorkflowExecutions, currentWorkflowExecutions,
workflowExecutionData, workflowExecutionData,
workflowExecutionPairedItemMappings, workflowExecutionPairedItemMappings,
workflowExecutionResultDataLastUpdate,
activeExecutionId: readonlyActiveExecutionId, activeExecutionId: readonlyActiveExecutionId,
previousExecutionId: readonlyPreviousExecutionId, previousExecutionId: readonlyPreviousExecutionId,
setActiveExecutionId, setActiveExecutionId,