🐛 Fix "unknown", never-end workflow and not displaying error message (#1978)

* Added try catch blocks to avoid endlessly running workflows

* Added handling for subworkflows

*  Fix one cause of "unkown" status of worklows with "main" mode

*  Fix one cause of "unkown" status of worklows with "own" mode

*  Fix one cause of "unkown" status of worklows with "queue" mode

* Saving database recovery

* 🐛 Fix issue that errors did not get saved correctly and also not
displayed

*  Save workflow timeout correctly as error

* Adding error capture to queued jobs

*  Mark canceled executions as not finished consistently across all
modes

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Omar Ajoue
2021-07-10 11:34:41 +02:00
committed by GitHub
parent abc2f2a515
commit d3da5023f0
7 changed files with 232 additions and 97 deletions

View File

@@ -213,33 +213,16 @@ export const pushConnection = mixins(
const runDataExecuted = pushData.data;
let runDataExecutedErrorMessage;
const runDataExecutedErrorMessage = this.$getExecutionError(runDataExecuted.data.resultData.error);
// @ts-ignore
const workflow = this.getWorkflow();
if (runDataExecuted.finished !== true) {
// There was a problem with executing the workflow
let errorMessage = 'There was a problem executing the workflow!';
if (runDataExecuted.data.resultData.error && runDataExecuted.data.resultData.error.message) {
let nodeName: string | undefined;
if (runDataExecuted.data.resultData.error.node) {
nodeName = typeof runDataExecuted.data.resultData.error.node === 'string'
? runDataExecuted.data.resultData.error.node
: runDataExecuted.data.resultData.error.node.name;
}
const receivedError = nodeName
? `${nodeName}: ${runDataExecuted.data.resultData.error.message}`
: runDataExecuted.data.resultData.error.message;
errorMessage = `There was a problem executing the workflow:<br /><strong>"${receivedError}"</strong>`;
}
runDataExecutedErrorMessage = errorMessage;
this.$titleSet(workflow.name as string, 'ERROR');
this.$showMessage({
title: 'Problem executing workflow',
message: errorMessage,
message: runDataExecutedErrorMessage,
type: 'error',
});
} else {

View File

@@ -3,6 +3,7 @@ import { ElNotificationOptions } from 'element-ui/types/notification';
import mixins from 'vue-typed-mixins';
import { externalHooks } from '@/components/mixins/externalHooks';
import { ExecutionError } from 'n8n-workflow';
export const showMessage = mixins(externalHooks).extend({
methods: {
@@ -15,6 +16,27 @@ export const showMessage = mixins(externalHooks).extend({
return Notification(messageData);
},
$getExecutionError(error?: ExecutionError) {
// There was a problem with executing the workflow
let errorMessage = 'There was a problem executing the workflow!';
if (error && error.message) {
let nodeName: string | undefined;
if (error.node) {
nodeName = typeof error.node === 'string'
? error.node
: error.node.name;
}
const receivedError = nodeName
? `${nodeName}: ${error.message}`
: error.message;
errorMessage = `There was a problem executing the workflow:<br /><strong>"${receivedError}"</strong>`;
}
return errorMessage;
},
$showError(error: Error, title: string, message?: string) {
const messageLine = message ? `${message}<br/>` : '';
this.$showMessage({

View File

@@ -375,6 +375,39 @@ export default mixins(
});
this.$externalHooks().run('execution.open', { workflowId: data.workflowData.id, workflowName: data.workflowData.name, executionId });
if (data.finished !== true && data.data.resultData.error) {
// Check if any node contains an error
let nodeErrorFound = false;
if (data.data.resultData.runData) {
const runData = data.data.resultData.runData;
errorCheck:
for (const nodeName of Object.keys(runData)) {
for (const taskData of runData[nodeName]) {
if (taskData.error) {
nodeErrorFound = true;
break errorCheck;
}
}
}
}
if (nodeErrorFound === false) {
const errorMessage = this.$getExecutionError(data.data.resultData.error);
this.$showMessage({
title: 'Failed execution',
message: errorMessage,
type: 'error',
});
if (data.data.resultData.error.stack) {
// Display some more information for now in console to make debugging easier
// TODO: Improve this in the future by displaying in UI
console.error(`Execution ${executionId} error:`);
console.error(data.data.resultData.error.stack);
}
}
}
},
async openWorkflowTemplate (templateId: string) {
this.setLoadingText('Loading template');