Create a counter

Hello.

I need to create a workflow that has a counter to delivery the following soluction:

There are an application that has a wait status, and I need to send a message showing how long the people are waiting. On workflow has two timers (sleep command) that wait 5 and 10 minutes. After second timer (10min), there is a loop that sends message every 10 minutes, in other words, a first time, the message has 15 minutes, every loop, this will be add 10 minutes and the Teams message sending 25, 35, 45 minutes…

I made this using Set node, but while it is manually, Is there a way to increase this cout automatically?

Hey @leucotron!

You can use the Function node for this. The $item() method can be used here to get the value for each execution. Function | Docs

You will have to create a loop so that these actions are performed continuously.

Hey @harshil1712, Thank you for reply.

Using Function node, do I need to use Set node too?

Hey @harshil1712, could you help about this workflow?
We are using the Function node to generate the the counter and the dynamic Teams message.
The first time, it works, and send “15 minutes” on Teams, but in the loop, this value don’t change, it’ always 15 minutes.
We are trying to use a variable to keep the last value after the Function node, but this variable don’t works.
Where is wrong?
Thanks.

Hey @leucotron!

I would set the initial value out of the loop using the Set node and manipulate this value inside the loop. Currently, you’re setting the initial value in the loop. Every time the loop runs, this initial value is set. The following image might give you a better idea

Hey @harshil1712, we made the workflow following your exemple and it worked, it create a variable and change this value acording the loop.
As we are not using a Database to store the variable (I think that the flow uses an internal buffer from our n8n instance), some times our workflow stop working, like the variable was lost, for exemple, after 20 minutes, it stops sending the message. I’m rigth? Can this internal buffer causing the problem?

Hey!

Did you changed the timeout for your workflows? I think due to the default timeout the workflow stops the execution.

No…
How can I do this?

You can do this via the below mentioned steps:

  1. Select Settings from the Workflow menu
  2. Toggle Timeout Workflow to true.
  3. Set the timeout value

1 Like

I’ll try this. Tanks.

Hey @harshil1712, I changed the workflow timeout, and make that it has up to 30 minutes, it working, but occours often “Unknown Status” and the workflow stop working.
How can I discovery the error?

Hey @leucotron!

If you click on the folder icon, it will show you the execution and the data that gets passed through the nodes in the workflow.

Hey @harshil1712, clicking on the folder icon is not showing nothing, but I noticed that n8n container is rebooting some times during the day, I’ll oberve it.

If the container restarts it is a sign that n8n crashed. That happens normally if it runs out of memory. That would then also explain the “Unknown” status.

Hey @jan, this afternoon the container didn’t crash and the workflow works fine all time.
Is there a log that I can see the out of memory?
How can I fix it? Do I increasing RAM memory can help?

n8n does not have a log for that.

You can try two things:

  1. Increasing the RAM as you mentioned
  2. If you do not run n8n already in “main” mode and rather in the default “own” switch over. You can find the documentation here.

Hey @jan, I increase the RAM, but didn’t work, the workflow continue as Unknown status, but the n8n containers is ok right now.

Using docker logs -f root_n8n_1 command, there are this:

Editor is now accessible via:
https://hub.leucotron.com.br:5678/
events.js:292
throw er; // Unhandled ‘error’ event
^

Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted ‘error’ event on TLSSocket instance at:
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -104,
code: ‘ECONNRESET’,
syscall: ‘read’
}

Hey @leucotron,

Did you change the mode from main to own?

I took a look at what the error means and this is what I found: sockets - How do I debug error ECONNRESET in Node.js? - Stack Overflow

From what has been shared in the above link, it is possible that the API errors out and doesn’t send a response back to n8n, causing the above error.

Hey @harshil1712 , thanks for reply.

About " Did you change the mode from main to own ?" I read the n8n documentation but I didn’t understantd how to do that. I mean, How to use the “export EXECUTIONS_PROCESS=own” command? Do I need to send it on docker-compose or on n8n container shell? Could you help me about this?

Hey @harshil1712
I made the docker-compose change. Is it right?
screenshot