Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Ensure runners do not throw on unsupported console methods #12167

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Dec 11, 2024

@@ -130,6 +130,21 @@ export class JsTaskRunner extends TaskRunner {
.join(' ');
void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
},
// dummy methods to disregard without throwing, following existing Code node behavior
Copy link
Member

@netroy netroy Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding a list that we need to maintain, we could use Object.keys(console).

so, something like this perhaps?

		const noOp = () => {};
		const customConsole = {
			...Object.keys(console).reduce((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[]) => {
				const logOutput = args
					.map((arg) => (typeof arg === 'object' && arg !== null ? JSON.stringify(arg) : arg))
					.join(' ');
				void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
			},
		};

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Dec 11, 2024
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

cypress bot commented Dec 11, 2024

n8n    Run #8298

Run Properties:  status check passed Passed #8298  •  git commit 74f3cb6357: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 ivov 🗃️ e2e/*
Project n8n
Branch Review pay-2353-typeerror-consoleerror-is-not-a-function
Run status status check passed Passed #8298
Run duration 04m 42s
Commit git commit 74f3cb6357: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 ivov 🗃️ e2e/*
Committer Iván Ovejero
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 480
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit 57c6a61 into master Dec 11, 2024
37 checks passed
@ivov ivov deleted the pay-2353-typeerror-consoleerror-is-not-a-function branch December 11, 2024 17:37
@github-actions github-actions bot mentioned this pull request Dec 19, 2024
@janober
Copy link
Member

janober commented Dec 19, 2024

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants