Add functionality to send console.log messages to editor-UI (#1816)

*  Send console.log messages to editor-UI

*  Send message only to session which started workflow

*  Made it also work in own process

*  Add support for console.log UI forward also to FunctionItem Node

* 👕 Fix lint issue

* 👕 Fix linting issue

*  Improve code

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Jan
2021-05-29 13:41:25 -05:00
committed by GitHub
parent 8e793e27b3
commit 4946bfcd3e
11 changed files with 84 additions and 11 deletions

View File

@@ -627,7 +627,7 @@ export async function executeWorkflow(workflowInfo: IExecuteWorkflowInfo, additi
// If no timeout was given from the parent, then we use our timeout.
subworkflowTimeout = Math.min(additionalData.executionTimeoutTimestamp || Number.MAX_SAFE_INTEGER, Date.now() + (workflowData.settings.executionTimeout as number * 1000));
}
additionalDataIntegrated.executionTimeoutTimestamp = subworkflowTimeout;
@@ -663,6 +663,24 @@ export async function executeWorkflow(workflowInfo: IExecuteWorkflowInfo, additi
}
export function sendMessageToUI(source: string, message: string) {
if (this.sessionId === undefined) {
return;
}
// Push data to session which started workflow
try {
const pushInstance = Push.getInstance();
pushInstance.send('sendConsoleMessage', {
source: `Node: "${source}"`,
message,
}, this.sessionId);
} catch (error) {
Logger.warn(`There was a problem sending messsage to UI: ${error.message}`);
}
}
/**
* Returns the base additional data without webhooks
*
@@ -785,4 +803,3 @@ export function getWorkflowHooksMain(data: IWorkflowExecutionDataProcess, execut
return new WorkflowHooks(hookFunctions, data.executionMode, executionId, data.workflowData, { sessionId: data.sessionId, retryOf: data.retryOf as string });
}