Method Date.prototype.toISOString called on incompatible receiver [object Date]

Hello after upgrading to latest 0.221.2, all of sudden my code function node which its pervious node is a sql query returns the below error.

There might not be enough memory to finish the execution. Tips for avoiding this [here](https://docs.n8n.io/flow-logic/error-handling/memory-errors/)

I have drilled it down the issue is that something is not handling created_at and updated_at fields that is returned correctly, attaching the sql query to another node such as a list node produces no errors… interstingly enough, if I have the node open and excute the node, no issues, it is only when I run the workflow manually or via cron or another workflow trigger.

Screenshot 2023-03-26 at 8.46.27 PM

Simple querey throws the below error

SELECT updated_at, created_at FROM TABLE

This is the schema for created_at and updated_at (defualt mysql)
CREATE TABLE t1 (
created_at TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
);

here are sample values

updated_at: 2023-03-27 03:00:18
created_at: 2023-03-26 08:01:42	

mysql node returns 
[

{
"updated_at":
"2023-03-27T03:00:18.000Z",
"created_at":
"2023-03-25T22:31:42.000Z"
},
]
    at Proxy.toISOString (<anonymous>)
    at Proxy.toJSON (<anonymous>)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:182:21)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:217:25)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:221:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:221:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:217:25)
    at stringifyFnReplacer (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringify (/usr/local/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:598:18)
    at Format.transform (/usr/local/lib/node_modules/n8n/node_modules/logform/json.js:28:19)
    at DerivedLogger._transform (/usr/local/lib/node_modules/n8n/node_modules/winston/lib/winston/logger.js:313:29)
    at DerivedLogger.Transform._read (/usr/local/lib/node_modules/n8n/node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:166:10)
    at DerivedLogger.Transform._write (/usr/local/lib/node_modules/n8n/node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:155:83)
    at doWrite (/usr/local/lib/node_modules/n8n/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:390:139)
    at writeOrBuffer (/usr/local/lib/node_modules/n8n/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:381:5)
    at DerivedLogger.Writable.write (/usr/local/lib/node_modules/n8n/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:302:11)
    at DerivedLogger.log (/usr/local/lib/node_modules/n8n/node_modules/winston/lib/winston/logger.js:252:14)
    at Logger.log (/usr/local/lib/node_modules/n8n/dist/Logger.js:57:21)
    at Logger.error (/usr/local/lib/node_modules/n8n/dist/Logger.js:66:14)
    at WorkflowRunnerProcess.sendHookToParentProcess (/usr/local/lib/node_modules/n8n/dist/WorkflowRunnerProcess.js:215:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at WorkflowHooks.hookFunctions.workflowExecuteAfter (/usr/local/lib/node_modules/n8n/dist/WorkflowRunnerProcess.js:237:21)
    at WorkflowHooks.executeHookFunctions (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/WorkflowHooks.js:17:17)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:774:17
Method Date.prototype.toISOString called on incompatible receiver [object Date]

Same issue here with .toISOstring method. It seems like it is returning data in other format - this was working fine last week.

It looks like your input also includes timestamp in Zulu format similar to my node which is producing the error. This might be a bug in the node, I was not even using the timestamp in the node but still throwing an error.

Hey @roozbehk,

I was about to reply back and say I was not able to reproduce this as it did work for me…

But that was a manual node execution, If I run the full thing with the Execute Workflow button it does indeed fail. (Quick update to mention that I missed you already mentioned this :+1:)

I will do a bit more testing and get an internal ticket created for this one, For now it would be worth downgrading to 0.220.1 which from a bit of testing works as expected.

Edit: Our internal reference for this is N8N-6282

2 Likes

Thank you for testing and reproducing the error, I will follow this thread for when the issue has been fixed.

1 Like

Hey folks, in case you’re still struggling with this, it’s due to some internal magic (internal slots) in how built-in classes like Date are implemented in JavaScript that make them incompatible with Proxy unless you manually detect them and explicitly bind the methods you’re returning to the non-proxified original.

These two diffs should illustrate how I fixed it in JSDB:

hth :slight_smile:

(Stumbled onto this while researching the error message.)

1 Like

Looks like I forgot to update this one, We fixed this a back here: fix(core): Handle Date and RegExp objects in AugmentObject by netroy · Pull Request #5809 · n8n-io/n8n · GitHub

:slight_smile:

1 Like

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