Increase pm2 service memory limit?

Describe the issue/error/question

I am getting messages when executing a code node of pretty small size that indicate a possible out of memory error.
I am running n8n via pm2 on my own virtual server, which has 16GB of memory available. I have not seen n8n use more than 300mb of memory.
Is there a configuration step I need to enable using more than 300mb of memory during executions?

Thanks in advance; I see some other posts that might be relevant, but they all seem to relate to cloud hosted instances, and don’t include any details other than “provision more memory” which I’m assuming means to the physical server.

What is the error message (if any)?

Information on your n8n setup

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

Hey @kcwebby,

It sounds like it is going to more of a pm2 question than an n8n one. I did a quick search online and found that if you are not using a pm2 ecosystem file you can do something like --node-args='--max-old-space-size=600M'

But you may not actually be hitting a memory limit, What is your workflow doing and what does the n8n output in the pm2 log say?

Hey @Jon ,

I didn’t see that n8n had anything in an error log; thanks for mentioning this.
This workflow has worked, and has gone mostly unchanged except a few n8n upgrades.

With this last upgrade, which skipped a few versions has made me start chasing resource issues; I’ve upgraded from sqlite to mysql (reimported workflows, no migration).

Here is the error for my log, repeated several times:

There was a problem running hook "workflowExecuteAfter" TypeError: Method Date.prototype.toISOString called on incompatible receiver [object Object]
    at Proxy.toISOString (<anonymous>)
    at Proxy.toJSON (<anonymous>)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:182:21)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:221:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:221:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:221:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:217:25)
    at stringifyFnReplacer (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:256:23)
    at stringify (/usr/lib/node_modules/n8n/node_modules/safe-stable-stringify/index.js:598:18)
    at Format.transform (/usr/lib/node_modules/n8n/node_modules/logform/json.js:28:19)
    at DerivedLogger._transform (/usr/lib/node_modules/n8n/node_modules/winston/lib/winston/logger.js:313:29)
    at DerivedLogger.Transform._read (/usr/lib/node_modules/n8n/node_modules/readable-stream/lib/_stream_transform.js:166:10)
    at DerivedLogger.Transform._write (/usr/lib/node_modules/n8n/node_modules/readable-stream/lib/_stream_transform.js:155:83)
    at doWrite (/usr/lib/node_modules/n8n/node_modules/readable-stream/lib/_stream_writable.js:390:139)
    at writeOrBuffer (/usr/lib/node_modules/n8n/node_modules/readable-stream/lib/_stream_writable.js:381:5)
    at DerivedLogger.Writable.write (/usr/lib/node_modules/n8n/node_modules/readable-stream/lib/_stream_writable.js:302:11)
    at DerivedLogger.log (/usr/lib/node_modules/n8n/node_modules/winston/lib/winston/logger.js:252:14)
    at Logger.log (/usr/lib/node_modules/n8n/src/Logger.ts:93:15)
    at Logger.error (/usr/lib/node_modules/n8n/src/Logger.ts:107:8)
    at WorkflowRunnerProcess.sendHookToParentProcess (/usr/lib/node_modules/n8n/src/WorkflowRunnerProcess.ts:342:16)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at WorkflowHooks.hookFunctions.workflowExecuteAfter (/usr/lib/node_modules/n8n/src/WorkflowRunnerProcess.ts:371:6)
    at WorkflowHooks.executeHookFunctions (/usr/lib/node_modules/n8n/node_modules/n8n-workflow/src/WorkflowHooks.ts:45:5)
    at /usr/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1242:6

And here is my workflow:

The place where it hangs:

You can see in the nodes, I’m taking nested JSON from the SNS trigger, breaking it out, and then running a series of regex to extract some matching data into fields for use in a telegram message.

Thanks!

Perfect, so that log error is something we know about and will be fixed soon. It sounds like it might not be a memory issue which is always good. For now can you install 0.220.1 and let me know if that works for you.

1 Like

I had the same issue as @kcwebby, and pulling the 0.220.1 fixed it. Thank you :smiley:

2 Likes

How does one roll back to 0.220.1 via npm/pm2 ?
I am afraid I’m not that well versed with node or pm2 just yet.

Thanks

Thanks all; I figured out that rolling back is just as easy as with git – npm install -g [email protected]
However, my workflow still has an error, although its an error I had after the one I previously pasted, and had assumed that was related to not being able to safely stop the execution (because of memory problems)

Error fetching feature flags ReferenceError: AbortSignal is not defined
    at PostHog.<anonymous> (/usr/lib/node_modules/n8n/node_modules/posthog-core/src/index.ts:460:6)
    at step (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:102:23)
    at Object.next (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:83:53)
    at /usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:76:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:72:12)
    at PostHogCoreStateless.fetchWithRetry (/usr/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:1063:16)
    at PostHog.<anonymous> (/usr/lib/node_modules/n8n/node_modules/posthog-core/src/index.ts:219:17)
    at step (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:102:23)
    at Object.next (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:83:53)
    at /usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:76:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:72:12)
    at PostHogCoreStateless.getDecide (/usr/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:833:16)
    at PostHog.<anonymous> (/usr/lib/node_modules/n8n/node_modules/posthog-core/src/index.ts:318:39)
    at step (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:102:23)
    at Object.next (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:83:53)
    at /usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:76:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:72:12)
    at PostHog.call [as getFeatureFlagsAndPayloadsStateless] (/usr/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.>
    at PostHog.<anonymous> (/usr/lib/node_modules/n8n/node_modules/posthog-node/src/posthog-node.ts:324:85)
    at step (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:102:23)
    at Object.next (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:83:53)
    at fulfilled (/usr/lib/node_modules/n8n/node_modules/node_modules/tslib/tslib.es6.js:73:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Hey @kcwebby,

Is that error causing the workflow to fail? In theory it shouldn’t break anything as it just for telemetry / enabling us to test small features.

@Jon thanks for asking. Yes the workflow is still failing with the same non descriptive error message (in the UI) and only what I pasted in my last in the PM2 error log.

Thanks in advance for your help!

@kcwebby that is interesting I wouldn’t have expected the same message in the ui.

Assuming it is just the one workflow with the error can you share it?

@Jon I am travelling this morning, away from my PC just now; but I did put the workflow in a prior reply; I’ll be back in a few hours and can paste it again if you can’t find it.

Hey @kcwebby,

You did I missed it, I guess a couple of other questions for when you are back… What version of node are you using and what OS are you running on (I assume Linux)

@Jon No problem.

I am running on Debian 11 Linux; with PM2, and I just downgraded to 220.1; I last remember it working on 218.1; so I might downgrade a bit further when I get back to the house in a couple hours.

Thanks!

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