node-red-contrib-ical-events icon indicating copy to clipboard operation
node-red-contrib-ical-events copied to clipboard

[BUG]: Query blocks node-red flows

Open ascha191 opened this issue 3 years ago • 12 comments

Describe the bug Every query of my iCal google calendar blocks the other node-red flows for 15 seconds and the node-red dashboard is not responding. I use a clock with a seconds display on my dashboard and you can see the problem very clearly there and it can always be reproduced.

To Reproduce Steps to reproduce the behavior:

  1. use the upcoming node
  2. google calender iCal - preview 12hours
  3. ouput is ok / correct

Expected behavior The remaining node-red flows should not be blocked by a query

**node-red-contrib-ical-events

  • Version 2.2.0
  • node-red version 2.2.0
  • is it an ical calendar

ascha191 avatar Feb 18 '22 10:02 ascha191

Hi @ascha191,

may I ask how many events in the calendar are? It must be really huge, if it takes 15 seconds ;) This may take some time to parse all the events, indeed.

I did a short test how NodeRED is reacting on a such long running query. My nextcloud calendar takes 5-6 seconds.

issue125

I have no dashboard, so I simple output a Timestamp to the debugging console. I don't know, why the dashboard doesn't update within the 15 seconds on your side... The debugging is responding...

I will take some more time, to check the behavior with a dashboard installed. Please be patient.

Regards, Benjamin

naimo84 avatar Feb 18 '22 18:02 naimo84

Ok, even with a dashbaord installed, the behavior is the same. At least on my side...

I'm very sorry, that this is happening on your side...

issue125_1

naimo84 avatar Feb 18 '22 18:02 naimo84

Hi Benjamin! Thanks for your quick answer!

The problem seems to occur even without a dashboard on my config. I tried a different iCal calendar. same problem.

Animation

My node-red installation runs on a Raspberry Pi 3 Model B ARM-Cortex-A53 4x 1.2GHz.

Any ideas?

ascha191 avatar Feb 18 '22 20:02 ascha191

Hi,

I've tested it on my Raspi 4 and NodeJs 12, but also on my Proxmox Server with NodeJs 10,12,14,16 and 17. I always getting a response from my "clock" every second...

I will ask a workmate of mine tomorrow. Perhaps he has an idea ;)

Currently I have no idea, why this is happening on your side... Sorry

naimo84 avatar Feb 20 '22 11:02 naimo84

It sounds like this from the official Node-RED forum: https://discourse.nodered.org/t/node-red-node-mysql-mysql-query-blocks-node-red/40688. I will have to implement a streaming, if I read it correctly. This may take some time, I'm afraid....

Is your CPU at 100% while querying the calendar data?

naimo84 avatar Feb 20 '22 11:02 naimo84

cpu usage jumps from about 10% to about 40%

ascha191 avatar Feb 20 '22 11:02 ascha191

issue125_2

Even with 100% CPU it's not blocking here...

naimo84 avatar Feb 20 '22 12:02 naimo84

Now I installed node-red on my Windows 11 with 6-core Ryzen CPU and tested the same simple flow. Same result. Time output is blocked for at least 2 seconds.

Node-RED version: v2.2.2 Node.js version: v16.14.0

Animation2

ascha191 avatar Feb 20 '22 18:02 ascha191

I see. Let's wait, what my workmate says to this ;)

I don't get it yet 😢

naimo84 avatar Feb 21 '22 05:02 naimo84

Thanks to @anweber, we've found the problem is a real big ical list. Processing this list takes some time. One thing I will try is to implement Worker Threads, the other thing is to optimize the loading and parsing logic. Both will take some time, unfortunately. As a quick fix, are you able to use a smaller calendar?

naimo84 avatar Feb 21 '22 18:02 naimo84

Ok. Thank you for your help! Maybe a stupid question: Isn't it possible to pre-filter the ical list when querying it from the server? As a workaround I increased the update cycle.

ascha191 avatar Feb 21 '22 19:02 ascha191

There is not stupid question 😉 Unfortunately Google (or better all ics/ical Provider) doesn't offer such a option. You can image the .ics file like a Textfile. You can only "download" it completely.

I also have on my list to implement the Google Calendar API. But this will tale even more more time ;)

naimo84 avatar Feb 22 '22 14:02 naimo84

Might be fixed with the latest version 👍 If not, feel free to comment or reopen it 😉

I've implemented worker threads and called it "experimental features", in order to not break others flows.

https://naimo84.github.io/kalender-events/guide/experimental.html

naimo84 avatar Sep 22 '23 07:09 naimo84