Eval method not working in 0.183.0

Hi Community!
while i was debugging one of our workflows, i stumpled upon some weird behaviour with the eval method. it seems to be disfunctional in newer versions of n8n.

Describe the issue/error/question

eval method always throws an error on execution on n8n version 0.183.0. ive tested it with an example from w3schools, and also tried to use $evaluateExpression, but the latter is somehow not doing anything (not sure if im using it correctly thou :smiley: )
the weird thing about that is - i’ve tested the exact same workflow with an older version of n8n (0.107.0) and it works perfectly fine. i have included my workflow below.

What is the error message (if any)?

on the newer version the error message reads: “x is not defined”

Please share the workflow

Share the output returned by the last node

ERROR: x is not defined [Line 7]

Details

Stack

ReferenceError: x is not defined
    at eval (eval at apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/setup-sandbox.js:371:10), <anonymous>:1:1)
    at eval (<anonymous>)
    at Object.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/setup-sandbox.js:371:10)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function:7:16
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function:13:2
    at BaseHandler.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:479:11)
    at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:425:23)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function/Function.node.js:96:31)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/src/Workflow.js:594:51)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:537:64

Information on your n8n setup

version with ERROR:

  • **n8n version:**0.183.0
  • **Database you’re using (default: SQLite):**not sure, probably default
  • **Running n8n with the execution process [own(default), main]:**not sure, probably default
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**Docker

version with NO ERROR:

  • **n8n version:**0.107.0
  • **Database you’re using (default: SQLite):**not sure, probably default
  • **Running n8n with the execution process [own(default), main]:**not sure, probably default
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**n8n cloud

let me know if theres any more information required, iirc in versions 0.182.0 and 0.181.0 it was also not working, but unfortunately i currently dont have access to instances running these versions.

thank you for reading! :slight_smile:

edit: we’ve just updated to the latest version (0.185.0) and the issue still persists.

Hey @strdl,

Try using the below line, It looks like the variable is not being passed in for some reason.

let text = `${x} * ${y}`;

hi @jon,

thank you for your reply! that actually worked. still weird that it doesnt work the same way it used to, but i can live with that :smiley:

thanks again and have a good day!