mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Code Node): Consistent redirection of stdout for JS and Python sandboxes (#6818)
Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
committed by
GitHub
parent
34df8b6238
commit
f718c2291f
@@ -92,8 +92,9 @@ export class Code implements INodeType {
|
||||
const nodeMode = this.getNodeParameter('mode', 0) as CodeExecutionMode;
|
||||
const workflowMode = this.getMode();
|
||||
|
||||
const node = this.getNode();
|
||||
const language: CodeNodeEditorLanguage =
|
||||
this.getNode()?.typeVersion === 2
|
||||
node.typeVersion === 2
|
||||
? (this.getNodeParameter('language', 0) as CodeNodeEditorLanguage)
|
||||
: 'javaScript';
|
||||
const codeParameterName = language === 'python' ? 'pythonCode' : 'jsCode';
|
||||
@@ -107,16 +108,16 @@ export class Code implements INodeType {
|
||||
context.item = context.$input.item;
|
||||
}
|
||||
|
||||
if (language === 'python') {
|
||||
context.printOverwrite = workflowMode === 'manual' ? this.sendMessageToUI : null;
|
||||
return new PythonSandbox(context, code, index, this.helpers);
|
||||
} else {
|
||||
const sandbox = new JavaScriptSandbox(context, code, index, workflowMode, this.helpers);
|
||||
if (workflowMode === 'manual') {
|
||||
sandbox.vm.on('console.log', this.sendMessageToUI);
|
||||
}
|
||||
return sandbox;
|
||||
}
|
||||
const Sandbox = language === 'python' ? PythonSandbox : JavaScriptSandbox;
|
||||
const sandbox = new Sandbox(context, code, index, this.helpers);
|
||||
sandbox.on(
|
||||
'output',
|
||||
workflowMode === 'manual'
|
||||
? this.sendMessageToUI
|
||||
: (...args) =>
|
||||
console.log(`[Workflow "${this.getWorkflow().id}"][Node "${node.name}"]`, ...args),
|
||||
);
|
||||
return sandbox;
|
||||
};
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
Reference in New Issue
Block a user