mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(core): Ensure runners do not throw on unsupported console methods (#12167)
This commit is contained in:
@@ -136,6 +136,36 @@ describe('JsTaskRunner', () => {
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it('should not throw when using unsupported console methods', async () => {
|
||||
const task = newTaskWithSettings({
|
||||
code: `
|
||||
console.warn('test');
|
||||
console.error('test');
|
||||
console.info('test');
|
||||
console.debug('test');
|
||||
console.trace('test');
|
||||
console.dir({});
|
||||
console.time('test');
|
||||
console.timeEnd('test');
|
||||
console.timeLog('test');
|
||||
console.assert(true);
|
||||
console.clear();
|
||||
console.group('test');
|
||||
console.groupEnd();
|
||||
console.table([]);
|
||||
return {json: {}}
|
||||
`,
|
||||
nodeMode: 'runOnceForAllItems',
|
||||
});
|
||||
|
||||
await expect(
|
||||
execTaskWithParams({
|
||||
task,
|
||||
taskData: newDataRequestResponse([wrapIntoJson({})]),
|
||||
}),
|
||||
).resolves.toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('built-in methods and variables available in the context', () => {
|
||||
|
||||
@@ -121,7 +121,13 @@ export class JsTaskRunner extends TaskRunner {
|
||||
nodeTypes: this.nodeTypes,
|
||||
});
|
||||
|
||||
const noOp = () => {};
|
||||
const customConsole = {
|
||||
// all except `log` are dummy methods that disregard without throwing, following existing Code node behavior
|
||||
...Object.keys(console).reduce<Record<string, () => void>>((acc, name) => {
|
||||
acc[name] = noOp;
|
||||
return acc;
|
||||
}, {}),
|
||||
// Send log output back to the main process. It will take care of forwarding
|
||||
// it to the UI or printing to console.
|
||||
log: (...args: unknown[]) => {
|
||||
|
||||
Reference in New Issue
Block a user