Describe the problem/error/question
Recently upgraded to 1.64.3, and my code node no longer works.
What is the error message (if any)?
{
“errorMessage”: “Cannot read properties of undefined (reading ‘forEach’) [line 7]”,
“errorDescription”: “TypeError”,
“errorDetails”: {},
“n8nDetails”: {
“nodeName”: “Code - Find all orders not complete”,
“nodeType”: “n8n-nodes-base.code”,
“nodeVersion”: 2,
“n8nVersion”: “1.64.3 (Cloud)”,
“binaryDataMode”: “filesystem”,
“stackTrace”: [
“TypeError: Cannot read properties of undefined (reading ‘forEach’)”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:7:16",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)“,
" at Proxy.reduce ()”,
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)“,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:3:30”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:25:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)“,
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:497:23)”,
" at JavaScriptSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox.js:50:45)“,
" at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:130:40)”
]
}
}
Please share your workflow
const items = $input.all();
const filteredOrders = items.reduce((acc, item) => {
const { orders, customerAccountNumbers, customData } = item.json;
const PRODUCT = customData.PRODUCT.toUpperCase();
orders.order.forEach((order) => {
if (
order.product === PRODUCT &&
[“open”, “partially_filled”, “pending”].includes(order.status)
) {
acc.push({
…order,
customerAccountNumbers,
customData,
});
}
});
return acc;
}, );
return filteredOrders;
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.64.3
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: