Code generation from strings disallowed for this context - when task runners are on

I updated to version 1.80.5 and according to the recommendation in the logs I set N8N_RUNNERS_ENABLED=true.

After that the Handlebars templating engine enabled via NODE_FUNCTION_ALLOW_EXTERNAL=handlebars variable stopped working.

Having rolled back the settings, the templating worked again.

Stack trace:

EvalError: Code generation from strings disallowed for this context at JavaScriptCompiler.Function (<anonymous>) at JavaScriptCompiler.createFunctionContext (/usr/local/lib/node_modules/n8n/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23) at JavaScriptCompiler.compile (/usr/local/lib/node_modules/n8n/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:144:19) at compileInput (/usr/local/lib/node_modules/n8n/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:510:53) at ret (/usr/local/lib/node_modules/n8n/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:517:18) at VmCodeWrapper (evalmachine.<anonymous>:12:21) at evalmachine.<anonymous>:15:2 at Script.runInContext (node:vm:149:12) at runInContext (node:vm:301:6) at result (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js:162:63)

JS Function v1:

const Handlebars = require('handlebars');

let source = $node["FindTemplate"].json["json_message"];

let template = Handlebars.compile(source);

let template_values = $node["FindEvent"].json["data"];
template_values.updated_at = $node["Date_Time"].json["date_time"];

var result = {};

result["message"] = template(template_values);

return result;

Very handy templating that I wouldn’t want to change, but in future versions task runners will be the default.

I would like to know if there is any alternative or recommendation to replace Handlebars if it is not supported by task runners…

In fact, these are not backwards-compatible changes, which I didn’t see described in the release versions…

Information on your n8n setup

  • n8n version: 1.80.5
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Ubuntu 24.04
1 Like

Could you please advise, is there any way to continue using external functions on the runners?

I’m getting the same error on one of my Code nodes.

Can confirm, I have this error from version 1.89.x, onwards to 1.89.2

I upgraded to 1.91.3.

The problem continues on this version.

1 Like

Please advise if there will be any alternatives to these backward compatibility issues.

This issue goes on & on, still relevant on the latest version as of today.

@Jon Please advise, in order to consider fixing the problem, do I need to open an issue on GitHub?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.