fix(editor): Fix an infinite loop while loading executions that are not on the current executions list (#5071)

fix(editor): Fix an infinitine loop while loading executions that are not on the current executions list
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-01-03 14:40:51 +01:00 committed by GitHub
parent 0ec66bfb42
commit 8cf3c86860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -426,9 +426,9 @@ export default mixins(
.catch(() => {}); .catch(() => {});
} }
}, },
async tryToFindExecution(executionId: string, skipCheck = false): Promise<void> { async tryToFindExecution(executionId: string, attemptCount = 0): Promise<void> {
// First check if executions exists in the DB at all // First check if executions exists in the DB at all
if (!skipCheck) { if (attemptCount === 0) {
const executionExists = await this.workflowsStore.fetchExecutionDataById(executionId); const executionExists = await this.workflowsStore.fetchExecutionDataById(executionId);
if (!executionExists) { if (!executionExists) {
this.workflowsStore.activeWorkflowExecution = null; this.workflowsStore.activeWorkflowExecution = null;
@ -443,6 +443,10 @@ export default mixins(
return; return;
} }
} }
// stop if the execution wasn't found in the first 1000 lookups
if (attemptCount >= 10) return;
// Fetch next batch of executions // Fetch next batch of executions
await this.loadMore(100); await this.loadMore(100);
const execution = this.workflowsStore.getExecutionDataById(executionId); const execution = this.workflowsStore.getExecutionDataById(executionId);
@ -450,7 +454,7 @@ export default mixins(
// If it's not there load next until found // If it's not there load next until found
await this.$nextTick(); await this.$nextTick();
// But skip fetching execution data since we at this point know it exists // But skip fetching execution data since we at this point know it exists
await this.tryToFindExecution(executionId, true); await this.tryToFindExecution(executionId, attemptCount + 1);
} else { } else {
// When found set execution as active // When found set execution as active
this.workflowsStore.activeWorkflowExecution = execution; this.workflowsStore.activeWorkflowExecution = execution;